Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{make_nocache} outputs (un?)compiled code in final HTML output when using multiple includes #369

Closed
strikernl opened this issue May 31, 2017 · 1 comment

Comments

@strikernl
Copy link

strikernl commented May 31, 2017

When using {make_nocache} in a template with a parent that was included from another parent, I get unexpected uncompiled Smarty code in the final HTML output.

This is using Smarty 3.1.31.

Simple test case:

PHP

<?php

require('vendor/smarty/smarty/libs/Smarty.class.php');

$tpl = new Smarty();
$tpl->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
$tpl->assign('dir', __DIR__);
$tpl->display(__DIR__ . '/page1.tpl');

page1.tpl

{$var='test'}
{include file="{$dir}/layout.tpl" myvar=$var}

layout.tpl

{include file="{$dir}/layout_base.tpl" myvar2=$myvar}

layout_base.tpl

Hello world
{make_nocache $myvar2}
Bye world

Expected output

I expect the following output:

Hello world

Bye world

Actual output

Instead I get:

Hello world
/*%%SmartyNocache:1884390456592e9210e147c0_85763675%%*/<?php $_smarty_tpl->smarty->ext->_make_nocache->store($_smarty_tpl, 'myvar2', array(
   'value' => 'test',
   'nocache' => false,
));?>
/*/%%SmartyNocache:1884390456592e9210e147c0_85763675%%*/
Bye world

Misc

Interestingly enough, if I put the code from layout_base.tpl into layout.tpl instead, it does work as expected.

Also, if I insert <?> into layout_base.tpl, the undesired code also seems to disappear.

I.e.

Hello world
{make_nocache $myvar2}
Bye world
<?>

Outputs

Hello world

Bye world
<?>
uwetews added a commit that referenced this issue Aug 26, 2017
@uwetews
Copy link
Contributor

uwetews commented Aug 26, 2017

The fix is now in the master branch

@uwetews uwetews closed this as completed Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants