From cf22e986c0ebe5b42a366df1200347ebf62cb7a7 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Wed, 28 Mar 2018 07:14:29 +0200 Subject: [PATCH] - new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child} --- lexer/smarty_internal_templatelexer.plex | 10 +++++++--- lexer/smarty_internal_templateparser.y | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index 95d575ce..52ee2d7b 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -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; diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y index 45d7b194..d53cdf2d 100644 --- a/lexer/smarty_internal_templateparser.y +++ b/lexer/smarty_internal_templateparser.y @@ -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; }