|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jablko Smarty Rookie
Joined: 07 Apr 2006 Posts: 6
|
Posted: Tue Jul 31, 2007 7:52 pm Post subject: [PATCH] {capture append="..."} |
|
|
http://cgi.sfu.ca/~jdbates/tmp/smarty/200707310/patch
This patch was part of my Summer of Code project for Gallery last summer, to add an AJAX interface to the item administration system. The project is being merged into Gallery's trunk and this patch seems like a candidate for upstream.
It adds an "append" attribute to the {capture} compiler function, symmetric with the "assign" attribute. Like "assign" calls $this->assign(..., ob_get_contents()), this "append" attribute calls $this->append(..., ob_get_contents()).
This patch modifies ~10 lines and modifications are limited to _compile_capture_tag
The Gallery AJAX item admin interface uses the "append" attribute to divide templates' output into separate variables. In this way, one template can render both HTML output and the JavaScript to update that HTML after an AJAX callback:
<div id="foo"{if expr} style="display: none"{/if}>
[...]
</div>
{capture append="callbackOutput"}
{if expr}
document.getElementById("foo").style.display = "none";
{else}
document.getElementById("foo").style.display = "";
{/if}
{/capture}
HTML output is still returned by $smarty->fetch, but we use an output filter to replace content with $callbackOutput if the request was initiated by XmlHttpRequest.
Thanks, Jack |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Aug 01, 2007 9:26 am Post subject: |
|
|
looks good to me. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Aug 01, 2007 1:35 pm Post subject: |
|
|
added to CVS, please give it a test. |
|
Back to top |
|
|
|
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
|