Changeset 784

Show
Ignore:
Timestamp:
02/28/08 22:05:30 (11 months ago)
Author:
laurentj
Message:

fixed ticket #55: added support of multiline tags in templates

Files:

Legend:

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

    r742 r784  
    190190        $tplcontent = preg_replace("!{literal}(.*?){/literal}!s", '{literal}', $tplcontent); 
    191191 
    192         $tplcontent = preg_replace_callback("/{((.).*?)}/s", array($this,'_callback'), $tplcontent); 
     192        $tplcontent = preg_replace_callback("/{((.).*?)}/sm", array($this,'_callback'), $tplcontent); 
    193193 
    194194        $tplcontent = preg_replace('/\?>\n?<\?php/', '', $tplcontent); 
     
    224224            return ''; 
    225225        } else { 
    226             if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/',$tag,$m)) { 
     226            if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/ms',$tag,$m)) { 
    227227#if JTPL_STANDALONE 
    228228                throw new Exception(sprintf($this->_locales['errors.tpl.tag.function.invalid'], $tag, $this->_sourceFile)); 
     
    447447                        $this->doError2('errors.tpl.tag.constant.notallowed', $this->_currentTag, $str); 
    448448                    } 
     449                    if($type == T_WHITESPACE) 
     450                        $str = preg_replace("/(\s+)/ms"," ",$str); 
    449451                    $result.=$str; 
    450452                }else{ 
  • trunk/lib/jelix/tpl/jTplCompiler.class.php

    r742 r784  
    190190        $tplcontent = preg_replace("!{literal}(.*?){/literal}!s", '{literal}', $tplcontent); 
    191191 
    192         $tplcontent = preg_replace_callback("/{((.).*?)}/s", array($this,'_callback'), $tplcontent); 
     192        $tplcontent = preg_replace_callback("/{((.).*?)}/sm", array($this,'_callback'), $tplcontent); 
    193193 
    194194        $tplcontent = preg_replace('/\?>\n?<\?php/', '', $tplcontent); 
     
    224224            return ''; 
    225225        } else { 
    226             if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/',$tag,$m)) { 
     226            if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/ms',$tag,$m)) { 
    227227#if JTPL_STANDALONE 
    228228                throw new Exception(sprintf($this->_locales['errors.tpl.tag.function.invalid'], $tag, $this->_sourceFile)); 
     
    447447                        $this->doError2('errors.tpl.tag.constant.notallowed', $this->_currentTag, $str); 
    448448                    } 
     449                    if($type == T_WHITESPACE) 
     450                        $str = preg_replace("/(\s+)/ms"," ",$str); 
    449451                    $result.=$str; 
    450452                }else{ 
  • trunk/lib/jelix/tpl/jTplCompiler.class.php

    r742 r784  
    190190        $tplcontent = preg_replace("!{literal}(.*?){/literal}!s", '{literal}', $tplcontent); 
    191191 
    192         $tplcontent = preg_replace_callback("/{((.).*?)}/s", array($this,'_callback'), $tplcontent); 
     192        $tplcontent = preg_replace_callback("/{((.).*?)}/sm", array($this,'_callback'), $tplcontent); 
    193193 
    194194        $tplcontent = preg_replace('/\?>\n?<\?php/', '', $tplcontent); 
     
    224224            return ''; 
    225225        } else { 
    226             if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/',$tag,$m)) { 
     226            if (!preg_match('/^(\/?[a-zA-Z0-9_]+)(?:(?:\s+(.*))|(?:\((.*)\)))?$/ms',$tag,$m)) { 
    227227#if JTPL_STANDALONE 
    228228                throw new Exception(sprintf($this->_locales['errors.tpl.tag.function.invalid'], $tag, $this->_sourceFile)); 
     
    447447                        $this->doError2('errors.tpl.tag.constant.notallowed', $this->_currentTag, $str); 
    448448                    } 
     449                    if($type == T_WHITESPACE) 
     450                        $str = preg_replace("/(\s+)/ms"," ",$str); 
    449451                    $result.=$str; 
    450452                }else{ 
  • trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php

    r742 r784  
    124124        '<p>ok <?php  if(jAuth::isConnected()):?> connected <?php else:?> not connected <?php  endif; ?></p>', 
    125125        ), 
     1265=>array( 
     127        '<p>ok {zone $truc, 
     128                     array(\'toto\'=>4, 
     129                      \'bla\'=>\'foo\') 
     130                }</p>', 
     131        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p>', 
     132        ), 
     1336=>array( 
     134        '<p>ok {zone $truc, 
     135                     array(\'toto\'=>4, 
     136                      \'bla\'=>\'foo\') 
     137                }</p><div>{counter_init \'name\', \'0\', 1, 1}</div>', 
     138        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p><div><?php jtpl_function_common_counter_init( $t,\'name\', \'0\', 1, 1);?></div>', 
     139        ), 
    126140 
    127141); 
     
    141155        } 
    142156    } 
    143      
     157 
    144158    protected $tplerrors = array( 
    145159         0=>array('{if}', 
     
    148162                  'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 
    149163         ); 
    150      
     164 
    151165    function testCompileErrors() { 
    152166        $compil = new testJtplContentCompiler(); 
  • trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php

    r742 r784  
    124124        '<p>ok <?php  if(jAuth::isConnected()):?> connected <?php else:?> not connected <?php  endif; ?></p>', 
    125125        ), 
     1265=>array( 
     127        '<p>ok {zone $truc, 
     128                     array(\'toto\'=>4, 
     129                      \'bla\'=>\'foo\') 
     130                }</p>', 
     131        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p>', 
     132        ), 
     1336=>array( 
     134        '<p>ok {zone $truc, 
     135                     array(\'toto\'=>4, 
     136                      \'bla\'=>\'foo\') 
     137                }</p><div>{counter_init \'name\', \'0\', 1, 1}</div>', 
     138        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p><div><?php jtpl_function_common_counter_init( $t,\'name\', \'0\', 1, 1);?></div>', 
     139        ), 
    126140 
    127141); 
     
    141155        } 
    142156    } 
    143      
     157 
    144158    protected $tplerrors = array( 
    145159         0=>array('{if}', 
     
    148162                  'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 
    149163         ); 
    150      
     164 
    151165    function testCompileErrors() { 
    152166        $compil = new testJtplContentCompiler(); 
  • trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php

    r742 r784  
    124124        '<p>ok <?php  if(jAuth::isConnected()):?> connected <?php else:?> not connected <?php  endif; ?></p>', 
    125125        ), 
     1265=>array( 
     127        '<p>ok {zone $truc, 
     128                     array(\'toto\'=>4, 
     129                      \'bla\'=>\'foo\') 
     130                }</p>', 
     131        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p>', 
     132        ), 
     1336=>array( 
     134        '<p>ok {zone $truc, 
     135                     array(\'toto\'=>4, 
     136                      \'bla\'=>\'foo\') 
     137                }</p><div>{counter_init \'name\', \'0\', 1, 1}</div>', 
     138        '<p>ok <?php echo jZone::get($t->_vars[\'truc\'], array(\'toto\'=>4, \'bla\'=>\'foo\') );?></p><div><?php jtpl_function_common_counter_init( $t,\'name\', \'0\', 1, 1);?></div>', 
     139        ), 
    126140 
    127141); 
     
    141155        } 
    142156    } 
    143      
     157 
    144158    protected $tplerrors = array( 
    145159         0=>array('{if}', 
     
    148162                  'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 
    149163         ); 
    150      
     164 
    151165    function testCompileErrors() { 
    152166        $compil = new testJtplContentCompiler(); 
Download in other formats: Unified Diff Zip Archive