Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Trying to upgrade, having trouble with slashes and capture
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
qUJy5Xg0ve7k
Smarty Rookie


Joined: 15 Aug 2018
Posts: 15

PostPosted: Wed Aug 22, 2018 10:59 pm    Post subject: Reply with quote

In my example, I created foo and bar. So I would just have

Code:
$arr = array('bar', 'foo');


I created the names, so it's easy to have them in an array. I'm not sure why that would be impossible.

Code:
{capture name=columnA assign=columnA}
<td>I am columnA!</td>
{/capture}

{capture name=columnB assign=columnB}
<td>I am columnB!</td>
{/capture}

<tr>
{foreach from=$arr key=str}
{$smarty.capture.$str}
{/foreach}
</tr>

Now I can change the order of the columns by simply changing the order of the array. This actually maintains the business logic inside the array, which is created in the proper layer.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Aug 23, 2018 4:08 pm    Post subject: Reply with quote

Sorry to say it, but your example makes no sense.
What you are looking for is includes. Not captures.
You can use include inline to save on cache rendering.
Back to top
View user's profile Send private message
qUJy5Xg0ve7k
Smarty Rookie


Joined: 15 Aug 2018
Posts: 15

PostPosted: Fri Aug 24, 2018 12:57 am    Post subject: Reply with quote

So you are suggesting that I put each column in its own file, call the files foo.tmpl, bar.tmpl, then do the include in the for loop instead of the capture?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Aug 24, 2018 8:51 pm    Post subject: Reply with quote

Sounds about right. Assuming the demonstrated example is indeed the way you use captures.
Back to top
View user's profile Send private message
qUJy5Xg0ve7k
Smarty Rookie


Joined: 15 Aug 2018
Posts: 15

PostPosted: Mon Aug 27, 2018 4:08 pm    Post subject: Reply with quote

Update for future inquirers:

The bug fix was committed here: https://github.com/smarty-php/smarty/commit/8e09f97a147d6c637e541f61887b1ae893763bec

The code change is in libs/sysplugins/smarty_internal_compile_capture.php

The function compileSpecialVariable was changed to:

Code:

public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
{
    return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl'.(isset($parameter[ 1 ])?", {$parameter[ 1 ]})":')');
}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP