模版引擎总结之综合分析模版引擎
Velocity
渲染方式:一種渲染方式,java服務端渲染
-
java服務端渲染
語法:一種語法 ?-》 #:關鍵字使用#開頭 ?$:變量使用$開頭
artTemplate
渲染方式:兩種渲染方式,node服務端渲染、瀏覽器渲染
-
node服務端渲染
方式一:var str/function = template(fileName,data) ?-》fileName代表模版文件的路徑
方式二:template.compile(source, options); -》 返回渲染函數
方式三:template.render(source, data, options); -》返回渲染結果
-
瀏覽器渲染
引入:<script src="lib/template-web.js"></script>
方式一:vat str =?template(id, data);?
? ?? ? ?document.getElementById("content").innerHTML = str
語法:兩種語法 ? -》 標準語法【{{ }}】和原始語法【<%=、-、#、%、_ ? ? ? ? ?-、_%>】
其中原始語法兼容EJS(和EJS語法相同)
doT
渲染方式:兩種渲染方式,node服務端渲染、瀏覽器渲染
-
node服務端渲染
-
瀏覽器渲染
引入:?<script type="text/javascript" src="doT.js"></script>
方式一:var template = doT.template(str,options,data)
template(data)
語法:一種語法 ?-》【 {{=、~、?、!、#、## ? ? ? ?}}】
Jade
渲染方式:一種渲染方式,node服務端渲染
-
node服務端渲染
方式一:var str = jade.render(str,options)
方式二:var str = jade.rednderFile(fileName,options)
方式三:var template = jade.compile(str,options)
? ? ? ?template(data) ? ?-》返回字符串
方式四:var template = jade.complieFile(path,options)
template(data) ? ?-》返回字符串
方法五:var template = jade.compileClient(str,options)
template(data) -》返回函數,函數返回字符串
語法:一種語法 ?-》 縮進代表層級
EJS
渲染方式:兩種渲染方式,node服務端渲染、瀏覽器渲染
-
node服務端渲染
方式一:var str = ejs.render(str,data,options)
方式二:ejs.renderFile(fileName,data,options,function(err,data))
方式三:var template = ejs.compile(str,options)
template(data) -》 返回字符串
-
瀏覽器渲染
引入:<script src="./ejs.min.js"></script>
方式一:var str =?ejs.render(str,data,options)
方式二:var template = ejs.compile(str,options)
template(data)
語法:一種語法 ?-》 【<%=、-、#、%、_ ? ? ? ? ?-、_%>】
?
轉載于:https://www.cnblogs.com/kunmomo/p/11530628.html
總結
以上是生活随笔為你收集整理的模版引擎总结之综合分析模版引擎的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 增强学习Q-learning分析与演示(
- 下一篇: 后端系统开发之白名单机制