summaryrefslogtreecommitdiff
path: root/lib/phptal/PHPTAL/Tales.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-10-31 21:58:33 +0100
committeremkael <emkael@tlen.pl>2016-10-31 21:59:22 +0100
commitd216b3147bc3f37cf2337acab5767c6a4f74aa2e (patch)
tree6090989e5071db101a1112131e2b075a02dccbc4 /lib/phptal/PHPTAL/Tales.php
parentb23bfbb17d1d5f6852a1690f246a84c2d38ae969 (diff)
* PHPTAL library
Diffstat (limited to 'lib/phptal/PHPTAL/Tales.php')
-rw-r--r--lib/phptal/PHPTAL/Tales.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/phptal/PHPTAL/Tales.php b/lib/phptal/PHPTAL/Tales.php
new file mode 100644
index 0000000..571e85e
--- /dev/null
+++ b/lib/phptal/PHPTAL/Tales.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * PHPTAL templating engine
+ *
+ * PHP Version 5
+ *
+ * @category HTML
+ * @package PHPTAL
+ * @author Laurent Bedubourg <lbedubourg@motion-twin.com>
+ * @author Kornel LesiƄski <kornel@aardvarkmedia.co.uk>
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ * @version SVN: $Id$
+ * @link http://phptal.org/
+ */
+
+
+/**
+ * You can implement this interface to create custom tales modifiers
+ *
+ * Methods suitable for modifiers must be static.
+ *
+ * @package PHPTAL
+ * @subpackage Php
+ */
+interface PHPTAL_Tales
+{
+}
+
+
+/**
+ * translates TALES expression with alternatives into single PHP expression.
+ * Identical to phptal_tales() for singular expressions.
+ *
+ * Please use this function rather than PHPTAL_Php_TalesInternal methods.
+ *
+ * @see PHPTAL_Php_TalesInternal::compileToPHPExpressions()
+ * @return string
+ */
+function phptal_tale($expression, $nothrow=false)
+{
+ return PHPTAL_Php_TalesInternal::compileToPHPExpression($expression, $nothrow);
+}
+
+/**
+ * returns PHP code that will evaluate given TALES expression.
+ * e.g. "string:foo${bar}" may be transformed to "'foo'.phptal_escape($ctx->bar)"
+ *
+ * Expressions with alternatives ("foo | bar") will cause it to return array
+ * Use phptal_tale() if you always want string.
+ *
+ * @param bool $nothrow if true, invalid expression will return NULL (at run time) rather than throwing exception
+ * @return string or array
+ */
+function phptal_tales($expression, $nothrow=false)
+{
+ return PHPTAL_Php_TalesInternal::compileToPHPExpressions($expression, $nothrow);
+}
+