Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

nested block in child template doesnt work without {$smarty.block.child} inside #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create GrandParent tpl like this:
<html>
{block name=content}
{/block}
</html>

2. Create parent tpl:
{extends file="grandparent.tpl"}
{block name=content}
some content here

{block name=section1}
{/block}

{block name=section2}
Sect2 -- {$smarty.block.child} --- 
{/block}

{/block}

3. create child tpl:

{extends file="parent.tpl"}
{block name=section1}
la-la-la, section 1 here
{/block}

{block name=section2}
pa-pa-pa, section 2 here
{/block}

4. Now we see:

Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in 
template "parent.tpl" on line 5 "{/block}" unexpected closing tag' in 
Z:\home\mysite\smarty\sysplugins\smarty_internal_templatecompilerbase.php:657 
Stack trace: #0 
Z:\home\mysite\smarty\sysplugins\smarty_internal_compilebase.php(170): 
Smarty_Internal_TemplateCompilerBase->trigger_template_error('unexpected 
clos...', 5) #1 
Z:\home\mysite\smarty\sysplugins\smarty_internal_compile_block.php(243): 
Smarty_Internal_CompileBase->closeTag(Object(Smarty_Internal_SmartyTemplateCompi
ler), Array) #2 
Z:\home\mysite\smarty\sysplugins\smarty_internal_templatecompilerbase.php(465): 
Smarty_Internal_Compile_Blockclose->compile(Array, 
Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #3 
Z:\home\mysite\smarty\sysplugins\smarty_internal_templatecompilerbase.php(249): 
Smarty_Internal_TemplateCompilerBase->callTagCompiler('blockclose', Array, 
Array) #4 Z:\home\mysite\smarty\sys in

5. to avoid this problem we can add {$smarty.block.child} to parent.tpl:

{extends file="grandparent.tpl"}
{block name=content}
some content here

{block name=section1}
{$smarty.block.child}
{/block}

{block name=section2}
Sect2 -- {$smarty.block.child} --- 
{/block}

{/block}

6. Now it works, but in cost of couple hours of my lifetime and unexpected 
syntax :)

It was Smarty-3.1.12, On Win7 + denwer(WAMP Apache + PHP 5.3.13), 
welcome to email in case of any questions.

Original issue reported on code.google.com by yourick...@gmail.com on 19 Dec 2012 at 5:16

GoogleCodeExporter commented 9 years ago
A nested block with {$smarty.block.child} does fail if it follows a nested 
block without {$smarty.block.child}.

I will try to fix this ASAP

Original comment by Uwe.Tews@googlemail.com on 19 Dec 2012 at 8:53

GoogleCodeExporter commented 9 years ago
The bugfix is now in the SVN trunk and will later be included in 3.1.13

Original comment by Uwe.Tews@googlemail.com on 9 Jan 2013 at 11:06