runtime环境下的jade
jade除了支持服务器端,jade也支持客户端
runtime.jade
div
h3 jade runtime call
p this is from jade pre compile
命令行执行
jade --client --no-debug runtime.jade
执行完后就会生成一个runtime.js
function template(locals) { var buf = []; var jade_mixins = {}; var jade_interp; buf.push("<div><h3>jade runtime call</h3><p>this is from jade pre compile</p></div>");;return buf.join(""); }
如果模板文件很复杂,这里就会生成更多的代码结构,在文件里面调用
index.jade
#runtime
script(src="node_modules/jade/runtime.js")
script(src="runtime.js")
script.
var runtimeNode = document.getElementById('runtime');
var runtimeHtml = template({isRuntime:true})
runtimeNode.innerHTML = runtimeHtml;
=>
<div id="runtime"></div> <script src="node_modules/jade/runtime.js"></script> <script src="runtime.js"></script> <script> var runtimeNode = document.getElementById('runtime'); var runtimeHtml = template({isRuntime:true}) runtimeNode.innerHTML = runtimeHtml; </script>