Changeset 142

Show
Ignore:
Timestamp:
03/14/07 21:03:21 (2 years ago)
Author:
bermiferrer
Message:

Adding legacy support for conditional loops. They are accepted for enabling backwards compatibility. Removing conditional loops from generators

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AkActionView/TemplateEngines/AkSintags/AkSintagsLexer.php

    r140 r142  
    9898    function _addLoopTokens() 
    9999    { 
    100         $this->addSpecialPattern('{loop [A-Za-z][\.A-Za-z0-9_-]+}','Text','Loop'); 
     100        $this->addSpecialPattern('{loop [A-Za-z][\.A-Za-z0-9_-]+\??}','Text','Loop'); 
    101101    } 
    102102 
  • trunk/lib/AkActionView/TemplateEngines/AkSintags/AkSintagsParser.php

    r140 r142  
    239239    { 
    240240        if(AK_LEXER_SPECIAL === $state){ 
    241             $sintags_var = substr($match, 6,-1); 
     241            $sintags_var = rtrim(substr($match, 6,-1),'?'); 
    242242            $php_variable = $this->_convertSintagsVarToPhp($sintags_var); 
    243243            if($php_variable){ 
  • trunk/script/generators/scaffold/templates/installer.tpl

    r98 r142  
    1818    { 
    1919        $this->createTable('<?=$plural_name?>', " 
    20           id integer not null auto increment pk 
     20          id, 
     21          name, 
     22          description, 
     23          created_at, 
     24          updated_at 
    2125        ");   
    2226    } 
  • trunk/script/generators/scaffold/templates/view_listing.tpl

    r2 r142  
    1515  <tr> 
    1616    <?='<? '?>$content_columns = array_keys($<?=$model_name?>->getContentColumns()); ?> 
    17     {loop content_columns?
     17    {loop content_columns
    1818        <th scope="col"><?='<?= '?>$pagination_helper->sortable_link($content_column) ?></th> 
    1919    {end} 
     
    2121  </tr> 
    2222 
    23   {loop <?=$plural_name?>?
     23  {loop <?=$plural_name?>
    2424    <tr {?<?=$singular_name?>_odd_position}class="odd"{end}> 
    25     {loop content_columns?
     25    {loop content_columns
    2626      <td class="field"><?='<?= '?>$<?=$singular_name?>->get($content_column) ?></td> 
    2727    {end} 
  • trunk/test/fixtures/data/sintags_test_data.txt

    r138 r142  
    279279 
    280280 
     281=================================== 
     282 
     283{loop posts?} 
     284<q> {post.comment?} {post.author?} </q> 
     285{end} 
     286 
     287----------------------------------- 
     288 
     289 
     290<?php  
     291 empty($posts) ? null : $post_loop_counter = 0; 
     292 empty($posts) ? null : $posts_available = count($posts); 
     293 if(!empty($posts)) 
     294     foreach ($posts as $post_loop_key=>$post){ 
     295         $post_loop_counter++; 
     296         $post_is_first = $post_loop_counter === 1; 
     297         $post_is_last = $post_loop_counter === $posts_available; 
     298         $post_odd_position = $post_loop_counter%2; 
     299?> 
     300<q> <?php echo empty($post->comment) ? '' : $post->comment; ?> <?php echo empty($post->author) ? '' : $post->author; ?> </q> 
     301<?php } ?> 
     302 
     303 
     304