Example #1
0
 static function parse($tree)
 {
     extract($tree);
     if ($bool == '!') {
         $statement = "! ( {$statement} )";
     }
     $node = Block::parse($node);
     $children = Template::parse($children);
     return "<?php if ({$statement}): ?>{$node}{$children}<?php endif; ?>";
 }
Example #2
0
 static function parse($tree)
 {
     extract($tree);
     if (!$individual) {
         $individual = preg_match('/^\\$\\w+$/', $iterable) ? '$' . singular(trim($iterable, '$')) : '$item';
     }
     if ($individual == $iterable) {
         $individual = '$item';
     }
     $opening = "<?php foreach({$iterable} as \$i => {$individual}): ?>";
     $node = Block::parse($node);
     $children = Template::parse($children);
     $closing = "<?php endforeach; ?>";
     return $opening . $node . $children . $closing;
 }
Example #3
0
 protected static function setContent($content)
 {
     return is_array($content) ? Block::parseBlock($content) : $content;
 }
Example #4
0
 protected static function getContent(&$block)
 {
     extract(static::$tokens);
     if ($token = match($variableContent, $block)) {
         return Block::lex($token[0]);
     }
     if ($token = match($nodeContent, $block)) {
         return Block::lex($token[1]);
     }
     if ($token = match($yieldContent, $block)) {
         return Block::lex($token[0]);
     }
     if ($token = match($textContent, $block)) {
         return Block::lex("|{$token['0']}");
     }
 }