mirror of
https://github.com/Mibew/handlebars.php.git
synced 2024-11-15 08:44:12 +03:00
Fixed indentation / code style
This commit is contained in:
parent
41722af86d
commit
5257701669
@ -88,7 +88,7 @@ class Helpers
|
||||
* @var $args array
|
||||
* @var $source string
|
||||
*/
|
||||
if( is_numeric($args) ) {
|
||||
if ( is_numeric($args) ) {
|
||||
$tmp = $args;
|
||||
} else {
|
||||
$tmp = $context->get($args);
|
||||
|
@ -152,42 +152,42 @@ class Template
|
||||
break;
|
||||
}
|
||||
switch ($current[Tokenizer::TYPE]) {
|
||||
case Tokenizer::T_SECTION :
|
||||
$newStack = isset($current[Tokenizer::NODES])
|
||||
? $current[Tokenizer::NODES] : array();
|
||||
array_push($this->_stack, array(0, $newStack, false));
|
||||
$buffer .= $this->_section($context, $current);
|
||||
array_pop($this->_stack);
|
||||
break;
|
||||
case Tokenizer::T_INVERTED :
|
||||
$newStack = isset($current[Tokenizer::NODES]) ?
|
||||
$current[Tokenizer::NODES] : array();
|
||||
array_push($this->_stack, array(0, $newStack, false));
|
||||
$buffer .= $this->_inverted($context, $current);
|
||||
array_pop($this->_stack);
|
||||
break;
|
||||
case Tokenizer::T_COMMENT :
|
||||
$buffer .= '';
|
||||
break;
|
||||
case Tokenizer::T_PARTIAL:
|
||||
case Tokenizer::T_PARTIAL_2:
|
||||
$buffer .= $this->_partial($context, $current);
|
||||
break;
|
||||
case Tokenizer::T_UNESCAPED:
|
||||
case Tokenizer::T_UNESCAPED_2:
|
||||
$buffer .= $this->_get($context, $current, false);
|
||||
break;
|
||||
case Tokenizer::T_ESCAPED:
|
||||
case Tokenizer::T_SECTION :
|
||||
$newStack = isset($current[Tokenizer::NODES])
|
||||
? $current[Tokenizer::NODES] : array();
|
||||
array_push($this->_stack, array(0, $newStack, false));
|
||||
$buffer .= $this->_section($context, $current);
|
||||
array_pop($this->_stack);
|
||||
break;
|
||||
case Tokenizer::T_INVERTED :
|
||||
$newStack = isset($current[Tokenizer::NODES]) ?
|
||||
$current[Tokenizer::NODES] : array();
|
||||
array_push($this->_stack, array(0, $newStack, false));
|
||||
$buffer .= $this->_inverted($context, $current);
|
||||
array_pop($this->_stack);
|
||||
break;
|
||||
case Tokenizer::T_COMMENT :
|
||||
$buffer .= '';
|
||||
break;
|
||||
case Tokenizer::T_PARTIAL:
|
||||
case Tokenizer::T_PARTIAL_2:
|
||||
$buffer .= $this->_partial($context, $current);
|
||||
break;
|
||||
case Tokenizer::T_UNESCAPED:
|
||||
case Tokenizer::T_UNESCAPED_2:
|
||||
$buffer .= $this->_get($context, $current, false);
|
||||
break;
|
||||
case Tokenizer::T_ESCAPED:
|
||||
|
||||
$buffer .= $this->_get($context, $current, true);
|
||||
break;
|
||||
case Tokenizer::T_TEXT:
|
||||
$buffer .= $current[Tokenizer::VALUE];
|
||||
break;
|
||||
default:
|
||||
throw new \RuntimeException(
|
||||
'Invalid node type : ' . json_encode($current)
|
||||
);
|
||||
$buffer .= $this->_get($context, $current, true);
|
||||
break;
|
||||
case Tokenizer::T_TEXT:
|
||||
$buffer .= $current[Tokenizer::VALUE];
|
||||
break;
|
||||
default:
|
||||
throw new \RuntimeException(
|
||||
'Invalid node type : ' . json_encode($current)
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($stop) {
|
||||
@ -277,22 +277,22 @@ class Template
|
||||
$subexprs = array(); // will contain all subexpressions inside outermost brackets
|
||||
$lvl = 0;
|
||||
$cur_start = 0;
|
||||
for( $i=0; $i < strlen($params[2]); $i++ ) {
|
||||
$cur = substr( $params[2], $i, 1 );
|
||||
if( $cur == '(' ) {
|
||||
for ( $i=0; $i < strlen($params[2]); $i++ ) {
|
||||
$cur = substr($params[2], $i, 1);
|
||||
if ( $cur == '(' ) {
|
||||
if( $lvl == 0 ) $cur_start = $i+1;
|
||||
$lvl++;
|
||||
}
|
||||
if( $cur == ')' ) {
|
||||
if ( $cur == ')' ) {
|
||||
$lvl--;
|
||||
if( $lvl == 0 ) $subexprs[] = substr( $params[2], $cur_start, $i - $cur_start);
|
||||
if( $lvl == 0 ) $subexprs[] = substr($params[2], $cur_start, $i - $cur_start);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! empty( $subexprs ) ) {
|
||||
foreach( $subexprs as $expr ) {
|
||||
$cmd = explode( " ", $expr );
|
||||
$name = trim( $cmd[0] );
|
||||
if ( ! empty( $subexprs ) ) {
|
||||
foreach ( $subexprs as $expr ) {
|
||||
$cmd = explode(" ", $expr);
|
||||
$name = trim($cmd[0]);
|
||||
// construct artificial section node
|
||||
$section_node = array(
|
||||
Tokenizer::TYPE => Tokenizer::T_ESCAPED,
|
||||
@ -300,12 +300,12 @@ class Template
|
||||
Tokenizer::OTAG => $current[Tokenizer::OTAG],
|
||||
Tokenizer::CTAG => $current[Tokenizer::CTAG],
|
||||
Tokenizer::INDEX => $current[Tokenizer::INDEX],
|
||||
Tokenizer::ARGS => implode( " ", array_slice( $cmd, 1 ) )
|
||||
Tokenizer::ARGS => implode(" ", array_slice( $cmd, 1 ))
|
||||
);
|
||||
// resolve the node recursively
|
||||
$resolved = $this->_handlebarsStyleSection( $context, $section_node );
|
||||
$resolved = $this->_handlebarsStyleSection($context, $section_node);
|
||||
// replace original subexpression with result
|
||||
$params[2] = str_replace( '('.$expr.')', $resolved, $params[2] );
|
||||
$params[2] = str_replace('('.$expr.')', $resolved, $params[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user