NodeJS 模板引擎 Swig-NodeJS

码农软件 · 软件分类 · 模板引擎 · 2019-08-22 22:29:05

软件介绍

swig 是node端的一个优秀简洁的模板引擎,类似Python模板引擎Jinja,目前不仅在node端较为通用,相对于jadeejs优秀,而且在浏览器端也可以很好地运行。

特性:

  • 支持大多数主流浏览器。

  • 表达式兼容性好。

  • 面向对象的模板继承。

  • 将过滤器和转换应用到模板中的输出。

  • 可根据路劲渲染页面。

  • 支持页面复用。

  • 支持动态页面。

  • 可扩展、可定制。

使用示例:

模板代码

<h1>{{ pagename|title }}</h1>
<ul>
{% for author in authors %}
    <li{% if loop.first %} class="first"{% endif %}>{{ author }}</li>
{% endfor %}
</ul>

node.js 代码:

var swig  = require('swig');
var template = swig.compileFile('/absolute/path/to/template.html');
var output = template({
    pagename: 'awesome people',
    authors: ['Paul', 'Jim', 'Jane']
});

输出

<h1>Awesome People</h1>
<ul>
    <li class="first">Paul</li>
    <li>Jim</li>
    <li>Jane</li>
</ul>

本文地址:https://codercto.com/soft/d/12958.html

High-Performance Compilers for Parallel Computing

High-Performance Compilers for Parallel Computing

Michael Wolfe / Addison-Wesley / 1995-6-16 / USD 117.40

By the author of the classic 1989 monograph, Optimizing Supercompilers for Supercomputers, this book covers the knowledge and skills necessary to build a competitive, advanced compiler for parallel or......一起来看看 《High-Performance Compilers for Parallel Computing》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具