Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fouber/fis-parser-handlebars

A parser plugin for fis to precompile handlebars template.
https://github.com/fouber/fis-parser-handlebars

Last synced: 5 days ago
JSON representation

A parser plugin for fis to precompile handlebars template.

Awesome Lists containing this project

README

        

# fis-parser-handlebars (1.x)

A parser plugin for fis to precompile handlebars template.

> 注:本插件仅适用于1.x版本的handlebars,如果需要3.x版本,请访问 [这里](https://github.com/scrat-team/fis-parser-handlebars-3.x)

### 1. 安装插件:

> npm install -g fis-parser-handlebars

### 2. 配置

```js
// 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的模板文件,其中的内容是:
```hanblebars


{{title}}



{{body}}


```

创建foo.js的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版本](http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars.runtime-v3.0.3.js) 作为运行时模板引擎框架。