0.0.3 • Published 10 years ago
edp-provider-smarty4js v0.0.3
edp-provider-smarty4js
edp 的 smarty4js 支持模块,为 webserver 和 build 命令提供了预定配置
安装
npm install edp-provider-smarty4js --save-dev配置
创建 edp-smarty4js-config.js 配置
var eps = require('edp-provider-smarty4js');
// 默认配置
eps.config({
'left_delimiter': '{%',
'right_delimiter': '%}'
});
module.exports = exports = eps;在 edp-webserver-config.js 与 edp-build-config.js 顶部引入:
var eps = require('./edp-smarty4js-config.js');在 edp-webserver-config.js 对应部分添加:
var smarty4jsHandler = eps.webserver;
exports.getLocations = function () {
return [
// handlers
{
location: /\.tpl\.js($|\?)/,
handler: [
smarty4jsHandler({
extname: '.html',
complieOption: eps.config()
})
]
}
];
};在 edp-build-config.js 对应部分添加:
var Smarty4jsCompiler = eps.build;
new Smarty4jsCompiler({
files: [
'src/**/*.tpl.html'
],
complieOption: eps.config()
});搞定!
DEMO
git clone https://github.com/ecomfe/edp-provider-smarty4js.git
cd edp-provider-smarty4js
npm i
cd demo
edp build
edp webserver startsee: http://127.0.0.1:8868 or http://127.0.0.1:8868/output
相关
License
MIT © Baidu Inc.