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

No way to force caching for some value in a nocache tag #211

Closed
0xFEEDC0DE64 opened this issue Apr 9, 2016 · 2 comments
Closed

No way to force caching for some value in a nocache tag #211

0xFEEDC0DE64 opened this issue Apr 9, 2016 · 2 comments

Comments

@0xFEEDC0DE64
Copy link

There is no way to reenable caching in a nocaching tag. See the following example:

I set a nocache bool and some hard-to-calculate numbers:

$smarty->caching = true;
$smarty->assign('decision', false, true);
$smarty->assign('numberA', hardAlgorithmA());
$smarty->assign('numberB', hardAlgorithmB());
$smarty->display('display.tpl');

display.tpl

{if $decision}
    <p>{$numberA}</p>
{else}
    <p>{$numberB}</p>
{/if}

I want to get $numberA and $numberB to be cached in resulting template, the if itself not. This is currently not possible.

I think it could be easier if there would be a {cache} around the numbers to force caching?

@0xFEEDC0DE64
Copy link
Author

Any ideas to solve this?

@0xFEEDC0DE64 0xFEEDC0DE64 changed the title No way to enable caching in a nocache tag No way to force caching for some value in a nocache tag May 3, 2016
@uwetews
Copy link
Contributor

uwetews commented Jul 18, 2016

The dev-master version has already addressed this.
See #110
There is a new {make_nocache} tag.
Read the NEW_FEATURES.txt

{make_nocache $numberA}
{make_nocache $numberB}
{if $decision}
    <p>{$numberA}</p>
{else}
    <p>{$numberB}</p>
{/if}

Note that {make_nocache} must be called before the {if}

@uwetews uwetews closed this as completed Jul 18, 2016
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