0.0.1 • Published 10 years ago

fis-parser-handlebars v0.0.1

Weekly downloads
10
License
MIT
Repository
github
Last release
10 years ago

fis-parser-handlebars (1.x)

A parser plugin for fis to precompile handlebars template.

注:本插件仅适用于1.x版本的handlebars,如果需要3.x版本,请访问 这里

1. 安装插件:

npm install -g fis-parser-handlebars

2. 配置

// fis-conf.js
fis.config.set('modules.parser.handlebars', 'handlebars');
fis.config.set('project.fileType.text', 'handlebars');
fis.config.set('roadmap.ext.handlebars', 'js');

3. 使用

创建foo.handlebars的模板文件,其中的内容是:

<div class="entry">
  <h1>{{title}}</h1>
  <div class="body">
    {{body}}
  </div>
</div>

创建foo.js的js文件,内容是:

var tpl = __inline('foo.handlebars');
var context = {title: "My New Post", body: "This is my first post!"};
var html = console.log(tpl(context));
console.log(html);

在页面上引入handlebars的 runtime版本 作为运行时模板引擎框架。