nunjucks-cst

3.1.5 • Public • Published

Nunjucks-cst

Nunjucks is a full featured templating engine for javascript. It is heavily inspired by jinja2. View the docs here.

重要说明

由于nunjucks模板引擎不兼容emberjs的{{}}标签,所以修改了nunjucks模板引擎的标签占位符。

nunjucks默认占位符 修改后的占位符
{{ {$
}} $}
{# {@
#} @}

修改后使用nunjucks模板引擎解析的hexo插件会解析失败,所以需要同步修改依赖nunjucks模板引擎的hexo插件。

另外有一点很重要,如果你的其他hexo查询有依赖这个模板引擎,还必须要修改插件中的解析占位符。否则你安装的hexo查询将无效,比如xcoding中的搜索和RSS插件就是依赖这个模板引擎。所以需要修改他们的解析代码中的占位符。 如果你不想修改可以直接使用我已经修改好的插件。

已经修改过的插件:

之所以这么做是因为hexo使用nunjucks解析生成静态HTML。然后我的主站xcoding使用了GitHub+hexo搭建。然后博客主要用于记录EmberJS相关文章,EmberJS很多标签都是使用{{}},与模板引擎的占位符冲突。

冲突出现的问题如下:

http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 37, Column 81]
  expected variable end
 
 
Unhandled rejection Template render error: (unknown path) [Line 10, Column 95]
  unexpected token: #

当然也有其他解决方案,但是自定义模板占位符是比较好的方法,详细可以看如下博客: 如何从根本解决hexo不兼容{{}}标签问题

Installation

npm install nunjucks-cst

(View the CHANGELOG)

Documentation

See here.

Browser Support

Supported in all modern browsers. For IE8 support, use es5-shim.

Tests

Run the tests with npm test.

Watch master branch's tests running in the browser.

Mailing List

Join our mailing list and get help with and issues you have: https://groups.google.com/forum/?fromgroups#!forum/nunjucks

Want to help?

Contributions are always welcome! Before you submit an issue or pull request, please read our contribution guidelines.

Contributors

Readme

Keywords

Package Sidebar

Install

npm i nunjucks-cst

Weekly Downloads

1

Version

3.1.5

License

BSD-2-Clause

Unpacked Size

1.68 MB

Total Files

60

Last publish

Collaborators

  • ubuntuvim