在项目中结合使用 assign 和js_string

来源:互联网 发布:h5棋牌游戏源码 编辑:程序博客网 时间:2024/05/19 03:19
               [#if t.description??]
               [@text_cut s=t.description len=30 append='...'/]
               [#else]
               [#assign x]
               [@text_cut s=t.txt len=30 append=append/]
               [/#assign]
               <script>
               var temp ="${x?js_string}";
               temp = $('<div>').append(temp).text();
               //temp = temp.substring (3,temp.length-7);
               document.write(temp+"...");
               </script>

                [/#if]


在上面的例子中, 使用#assign 的复杂用法, 使得 @text_cut 的输出可以赋值给一个变量, 同时为了能在js中使用这个变量,使用了js_string的形式。

0 0
原创粉丝点击