- new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child}

This commit is contained in:
Uwe Tews
2018-03-28 07:14:29 +02:00
parent 0dbace8321
commit cf22e986c0
2 changed files with 19 additions and 3 deletions

View File

@@ -281,7 +281,7 @@ class Smarty_Internal_Templatelexer
ldel = ~(SMARTYldel)SMARTYal~ ldel = ~(SMARTYldel)SMARTYal~
rdel = ~\s*SMARTYrdel~ rdel = ~\s*SMARTYrdel~
nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~ nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~ smartyblockchildparent = ~[\$]smarty\.block\.(child|parent)~
integer = ~\d+~ integer = ~\d+~
hex = ~0[xX][0-9a-fA-F]+~ hex = ~0[xX][0-9a-fA-F]+~
math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~ math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
@@ -321,7 +321,6 @@ class Smarty_Internal_Templatelexer
as = ~\s+as\s+~ as = ~\s+as\s+~
to = ~\s+to\s+~ to = ~\s+to\s+~
step = ~\s+step\s+~ step = ~\s+step\s+~
block = ~block~
if = ~(if|elseif|else if|while)\s+~ if = ~(if|elseif|else if|while)\s+~
for = ~for\s+~ for = ~for\s+~
makenocache = ~make_nocache\s+~ makenocache = ~make_nocache\s+~
@@ -406,7 +405,12 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
ldel slash notblockid rdel { ldel smartyblockchildparent rdel {
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line;
}
ldel slash id rdel {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;

View File

@@ -324,6 +324,18 @@ smartytag(A)::= SIMPLETAG(B). {
} }
} }
} }
// {$smarty.block.child} or {$smarty.block.parent}
smartytag(A) ::= SMARTYBLOCKCHILDPARENT(i). {
$j = strrpos(i,'.');
if (i[$j+1] == 'c') {
// {$smarty.block.child}
A = $this->compiler->compileTag('child',array(),array(i));;
} else {
// {$smarty.block.parent}
A = $this->compiler->compileTag('parent',array(),array(i));;
}
}
smartytag(A) ::= LDEL tagbody(B) RDEL. { smartytag(A) ::= LDEL tagbody(B) RDEL. {
A = B; A = B;
} }