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

{$smarty.capture.$somevar} no longer works #478

Closed
ymTm7KuhCnIjkZAl2x2m2 opened this issue Aug 20, 2018 · 1 comment
Closed

{$smarty.capture.$somevar} no longer works #478

ymTm7KuhCnIjkZAl2x2m2 opened this issue Aug 20, 2018 · 1 comment

Comments

@ymTm7KuhCnIjkZAl2x2m2
Copy link

The following code and output should display the issue.

Template:

Smarty: {$smarty.version|escape}
<br />
PHP: {$phpversion}
<br />
{capture name=FooBar assign=FooBar}I am the foobar{/capture} 
{assign txt 'FooBar'} 
1: {$smarty.capture.FooBar}<br />
2: {$smarty.capture.$txt}<br />
3: {$smarty.capture[$txt]}<br />
4: {$txt}<br />
<!-- just in case it's caps lock related --> 
{capture name=baz assign=baz}I am the baz{/capture} 
{assign txt2 'baz'} 
5: {$smarty.capture.baz}<br />
6: {$smarty.capture.$txt2}<br />
7: {$smarty.capture[$txt2]}<br />
8: {$txt2}<br />

Output:

Smarty: 3.1.27 
PHP: 5.6.36 
1: I am the foobar
2: I am the foobar
3: I am the foobar
4: FooBar
5: I am the baz
6: I am the baz
7: I am the baz
8: baz
Smarty: 3.1.33-dev-5 
PHP: 5.6.36 
1: I am the foobar
2: 
3: 
4: FooBar
5: I am the baz
6: 
7: 
8: baz
ymTm7KuhCnIjkZAl2x2m2 pushed a commit to ymTm7KuhCnIjkZAl2x2m2/smarty that referenced this issue Aug 24, 2018
uwetews added a commit that referenced this issue Aug 25, 2018
…n Smarty special variable

    like $smarty.capture.$foo #478 #481
uwetews added a commit that referenced this issue Aug 25, 2018
…n Smarty special variable

    like $smarty.capture.$foo #478 #481
@uwetews
Copy link
Contributor

uwetews commented Aug 25, 2018

Please note that the Smarty special variables like $smarty.foo .... are no real variables and are not necessarily implemented as array. It is not specified that variable capture names can be used like
php $smarty.capture.$foo
However it did work unintended in some previous versions of Smarty

Access to variable capture blocks could be achieved by

{capture assign='bar'}
    buh
{/capture} 
 ....
{$foo}  // with $foo = 'bar'

Anyway I did add the variable capture name now as a feature

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