atpl-loader

0.2.0 • Public • Published

atpl-loader

NPM version Build Status Coverage Status NPM downloads

webpack loader for atpl.


Install

$ npm install atpl-loader -g

使用

配置

模板文件后缀为atpl,如index.atpl

语法

  • 变量输出以及逻辑语句
 
//左分割符为<%, 右分隔符为%>,暂不支持自定义
I am <%=name%>
//模板内支持JS逻辑,**不要在逻辑中声明out变量,内部使用**
<% if(name){ %>
  I am <%=name%>
<% }else{ %>
  Hello world !
<% } %>
 
  • 模板引用

目前版本尚未解决循环引用的问题,如a引用b,b又引用了a,实际使用中需注意

 
//引用其他的模板文件
I am <%include('./test/a.tpl')%>,and i like playing <%=man.game%>.
 

引用并渲染

 
// 引入模板
var tpl = require('./index.atpl');
// 数据源
var data = {
  ...
};
 
document.getElementById('#wrapper').innerHTML = tpl(data);
 

LISENCE

Copyright (c) 2015 chencheng. Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i atpl-loader

Weekly Downloads

14

Version

0.2.0

License

MIT

Last publish

Collaborators

  • sorrycc
  • yuanfei.gyf