1<?php
2/**
3 * PHPTAL templating engine
4 *
5 * PHP Version 5
6 *
7 * @category HTML
8 * @package  PHPTAL
9 * @author   Laurent Bedubourg <lbedubourg@motion-twin.com>
10 * @author   Kornel Lesiński <kornel@aardvarkmedia.co.uk>
11 * @license  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
12 * @version  SVN: $Id$
13 * @link     http://phptal.org/
14 */
15
16
17/**
18 * You can implement this interface to create custom tales modifiers
19 *
20 * Methods suitable for modifiers must be static.
21 *
22 * @package PHPTAL
23 * @subpackage Php
24 */
25interface PHPTAL_Tales
26{
27}
28
29
30/**
31 * translates TALES expression with alternatives into single PHP expression.
32 * Identical to phptal_tales() for singular expressions.
33 *
34 * Please use this function rather than PHPTAL_Php_TalesInternal methods.
35 *
36 * @see PHPTAL_Php_TalesInternal::compileToPHPExpressions()
37 * @return string
38 */
39function phptal_tale($expression, $nothrow=false)
40{
41    return PHPTAL_Php_TalesInternal::compileToPHPExpression($expression, $nothrow);
42}
43
44/**
45 * returns PHP code that will evaluate given TALES expression.
46 * e.g. "string:foo${bar}" may be transformed to "'foo'.phptal_escape($ctx->bar)"
47 *
48 * Expressions with alternatives ("foo | bar") will cause it to return array
49 * Use phptal_tale() if you always want string.
50 *
51 * @param bool $nothrow if true, invalid expression will return NULL (at run time) rather than throwing exception
52 * @return string or array
53 */
54function phptal_tales($expression, $nothrow=false)
55{
56    return PHPTAL_Php_TalesInternal::compileToPHPExpressions($expression, $nothrow);
57}
58
59