Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

yanhaijing/template-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template-loader license

template.js的webpakc编译loader——一款javascript模板引擎。

安装

$ npm install --save template_js@0.6.1 # 安装template运行时
$ npm install --save templatejs-loader # 安装template编译插件

注意:template_js 必须是0.6.1

配置

配置参数同template.js参数一样,其中expression参数会作为获取template的表达式。

loaders: [
    {
        test: /\.tmpl/,
        loader: "templatejs-loader",
        query: {
            sTag: '<#',
            eTag: '#>',
            expression: 'require("template_js")'
        }
    }
]

新建模版文件demo.tmpl

<div>
    <#=abc#>
</div>

在js中require模版文件,并渲染

var tpl = require('./demo.tmpl');

document.getElementById('test').innerHTML = tpl({abc: 'yanhaijing'});

demo

报告问题

作者

yanhaijing

更新日志

更新日志

相关链接