Changeset 1153

Show
Ignore:
Timestamp:
11/08/08 09:46:31 (2 months ago)
Author:
laurentj
Message:

jTpl: added the support of = syntax, to display complex expressions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/tpl/jTplCompiler.class.php

    r1145 r1153  
    154154 
    155155        $_dirname = jTplConfig::$cachePath.dirname($tplName).'/'; 
    156     echo $tplFile.'<br>'.$_dirname.'<br>'.$cachefile; 
     156 
    157157        if (!is_dir($_dirname)) {  
    158158                umask(0000);  
     
    231231 
    232232        // check the first character 
    233         if (!preg_match('/^\$|@|[a-zA-Z\/]$/',$firstcar)) { 
     233        if (!preg_match('/^\$|@|=|[a-zA-Z\/]$/',$firstcar)) { 
    234234#if JTPL_STANDALONE 
    235235            throw new Exception(sprintf($this->_locales['errors.tpl.tag.syntax.invalid'], $tag, $this->_sourceFile)); 
     
    239239        } 
    240240        $this->_currentTag = $tag; 
    241         if ($firstcar == '$' || $firstcar == '@') { 
     241        if ($firstcar == '=') { 
     242            return  '<?php echo '.$this->_parseVariable(substr($tag,1)).'; ?>'; 
     243        } else if ($firstcar == '$' || $firstcar == '@') { 
    242244            return  '<?php echo '.$this->_parseVariable($tag).'; ?>'; 
    243245        } else { 
  • trunk/lib/jelix/tpl/tests/compiler.php

    r1144 r1153  
    135135        '<p>ok <?php echo htmlspecialchars(constant($t->_vars[\'foo\']));?></p>', 
    136136        ), 
     13724=>array( 
     138        '<p>ok{=$foo.($truc.$bbb)}</p>', 
     139        '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 
     140        ), 
     14125=>array( 
     142        '<p>ok{=intval($foo.($truc.$bbb))}</p>', 
     143        '<p>ok<?php echo intval($t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\'])); ?></p>', 
     144        ), 
     145/*26=>array( 
     146        '', 
     147        '', 
     148        ), 
     14927=>array( 
     150        '', 
     151        '', 
     152        ),*/ 
    137153    ); 
    138154 
  • trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php

    r1141 r1153  
    142142        '<p>ok {const $foo}</p>', 
    143143        '<p>ok <?php echo htmlspecialchars(constant($t->_vars[\'foo\']));?></p>', 
     144        ), 
     14524=>array( 
     146        '<p>ok{=$foo.($truc.$bbb)}</p>', 
     147        '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 
     148        ), 
     14925=>array( 
     150        '<p>ok{=intval($foo.($truc.$bbb))}</p>', 
     151        '<p>ok<?php echo intval($t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\'])); ?></p>', 
    144152        ), 
    145153    ); 
Download in other formats: Unified Diff Zip Archive