mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
- new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child}
This commit is contained in:
@@ -281,7 +281,7 @@ class Smarty_Internal_Templatelexer
|
||||
ldel = ~(SMARTYldel)SMARTYal~
|
||||
rdel = ~\s*SMARTYrdel~
|
||||
nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
|
||||
notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~
|
||||
smartyblockchildparent = ~[\$]smarty\.block\.(child|parent)~
|
||||
integer = ~\d+~
|
||||
hex = ~0[xX][0-9a-fA-F]+~
|
||||
math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
|
||||
@@ -321,7 +321,6 @@ class Smarty_Internal_Templatelexer
|
||||
as = ~\s+as\s+~
|
||||
to = ~\s+to\s+~
|
||||
step = ~\s+step\s+~
|
||||
block = ~block~
|
||||
if = ~(if|elseif|else if|while)\s+~
|
||||
for = ~for\s+~
|
||||
makenocache = ~make_nocache\s+~
|
||||
@@ -406,7 +405,12 @@ class Smarty_Internal_Templatelexer
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
|
||||
$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->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
|
||||
$this->taglineno = $this->line;
|
||||
|
@@ -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. {
|
||||
A = B;
|
||||
}
|
||||
|
Reference in New Issue
Block a user