美文网首页
Script 标签内 使用 freemarker

Script 标签内 使用 freemarker

作者: sirai | 来源:发表于2017-06-27 09:27 被阅读30次
    • 赋值
      //循环list 赋值
            var templates = new Array();
            <#list datas as template>
                var template${template_index} = new Map();
                template${template_index}.put("id",'${template.id}');
                <#if template.smsContent??>
                    template${template_index}.put("smsContent",'${template.smsPrefix}${template.smsContent?replace("\r\n","</br>")?replace("\r","</br>")?replace("\n","</br>")}');
                </#if>
                <#if template.pushContent??>
                    template${template_index}.put("pushContent",'${template.pushContent?replace("\r\n","</br>")?replace("\r","</br>")?replace("\n","</br>")}');
                </#if>
                template${template_index}.put("model",'${template.model}');
                <#if template.tip??>
                    template${template_index}.put("tip",'${template.tip?replace("\r\n","</br>")?replace("\r","</br>")?replace("\n","</br>")}');
                </#if>
                templates.push(template${template_index});
            </#list>
    
    • 取值
    templates[val].get("pushContent")
    
    • freeMarker 值运算
     <#assign hour = ((sedentary.duration)/60)?int>
                        <#assign min = (sedentary.duration)%60>
                        <td>
                            <#if hour==0>
                        ${min}分钟
                        <#elseif min==0 >
                        ${hour}小时
                        <#else >
                        ${hour}小时${min}分钟
                        </#if>
                        </td>
    

    相关文章

      网友评论

          本文标题:Script 标签内 使用 freemarker

          本文链接:https://www.haomeiwen.com/subject/wzvscxtx.html