admin管理员组文章数量:1406918
We have this Smarty function that returns HTML code for templates. However it is also possible that the function returns a null string, which we now wish to identify. Our system has been running stably for years, so I am looking for the least invasive possible solution.
Is it possible to assign the return value to a smarty variable? I have tried assigning it to a Javascript variable, however, because part of the HTML is user generated, the return string could be a mixture of double and single quotes, which causes problems in IE (unfortunately the majority of our user base).
<script type="text/javascript">
var html = '{smarty function}'; //IE chokes on mixed quotes
</script>
Any help appreciated!
We have this Smarty function that returns HTML code for templates. However it is also possible that the function returns a null string, which we now wish to identify. Our system has been running stably for years, so I am looking for the least invasive possible solution.
Is it possible to assign the return value to a smarty variable? I have tried assigning it to a Javascript variable, however, because part of the HTML is user generated, the return string could be a mixture of double and single quotes, which causes problems in IE (unfortunately the majority of our user base).
<script type="text/javascript">
var html = '{smarty function}'; //IE chokes on mixed quotes
</script>
Any help appreciated!
Share Improve this question asked Jan 12, 2010 at 3:04 jodecijodeci 9962 gold badges11 silver badges18 bronze badges1 Answer
Reset to default 8Use escape
modifier, for example:
{$variable|escape:'quotes'}
For smarty function, you can first try if {smarty_function|escape:'quotes'}
works, if it doesn't then you have to assign the output of the function into a variable first before escaping it, and for that you use capture
:
{capture name=mycapture}{smarty_function}{/capture}
{$smarty.capture.mycapture|escape:'quotes'}
本文标签: phpdo things with the return value of smarty functionStack Overflow
版权声明:本文标题:php - do things with the return value of smarty function? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744365300a2602746.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论