Changeset 467 for trunk

Show
Ignore:
Timestamp:
01/16/08 17:27:18 (11 months ago)
Author:
gerd
Message:

Allow placeholders in LOOP attribute

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/example_attributes_loop.php

    r453 r467  
    3535    $heroes = array( 'Superman', 'Batman', 'Green Lantern', 'Robin', 'Wonder Woman', 'Powergirl' ); 
    3636    $tmpl->addVar( 'row', 'hero', $heroes ); 
     37 
     38    $tmpl->addVar( 'list', 'hero', $heroes ); 
     39    $tmpl->addVar( 'list', 'rows', 8 ); 
    3740     
     41    $tmpl->addVar( 'list2', 'hero', $heroes ); 
     42    $tmpl->addGlobalVar( 'global_rows', 19 ); 
    3843    $tmpl->displayParsedTemplate(); 
    3944?> 
  • trunk/examples/templates/example_attributes_loop.tmpl

    r229 r467  
    55    {PAT_ROW_VAR} {HERO}<br /> 
    66    </patTemplate:tmpl> 
     7    <hr /> 
     8    <patTemplate:tmpl name="list" loop="{ROWS}"> 
     9    {PAT_ROW_VAR} {HERO}<br /> 
     10    </patTemplate:tmpl> 
     11    <hr /> 
     12    <patTemplate:tmpl name="list2" loop="{GLOBAL_ROWS}"> 
     13    {PAT_ROW_VAR} {HERO}<br /> 
     14    </patTemplate:tmpl> 
    715 
    816</patTemplate:tmpl> 
  • trunk/patTemplate.php

    r464 r467  
    15881588             */ 
    15891589            $this->_fetchVariables($template); 
     1590 
     1591            /** 
     1592             * Allow placeholder ins loop attribute 
     1593             */ 
     1594            if ($start == $i) { 
     1595                if (strstr($this->_templates[$template]['attributes']['loop'], $this->_startTag) && preg_match('/'.$this->_startTag.'([A-Z\_]+)'.$this->_endTag.'/', $this->_templates[$template]['attributes']['loop'], $match)) { 
     1596                    if (isset($this->_vars[$template]['scalar'][$match[1]])) { 
     1597                        $this->_templates[$template]['loop']    =   intval(str_replace( '{' . $match[1] . '}', $this->_vars[$template]['scalar'][$match[1]] , $this->_templates[$template]['attributes']['loop'])); 
     1598                    } 
     1599                    else if (isset($this->_globals[$match[1]])) { 
     1600                        $this->_templates[$template]['loop']    =   intval(str_replace( '{' . $match[1] . '}', $this->_globals[$match[1]] , $this->_templates[$template]['attributes']['loop'])); 
     1601                    } 
     1602                } 
     1603            } 
    15901604 
    15911605            /**