10.0.9 • Published 7 years ago

isv-xtemplate-loader v10.0.9

Weekly downloads
4
License
MIT
Repository
gitlab
Last release
7 years ago

xtemplate-loader for webpack

xtemplate loader for webpack. Uses xtemplate function to compile templates.

Installation

npm install @ali/xtemplate-loader

Usage 1

Documentation: Using loaders

./index.xtpl

{{var}} 我编译好了!!! 
var template = require("@ali/xtemplate-loader!./index.xtpl");
// => returns the template function compiled with xtemplate templating engine.
var data = {var : "啊"};
var html = template(data);
console.log(html);// => 啊 我编译好了!!! 

Usage 2

Config example:

module.exports = {
  module: {
    loaders: [
      { test: /\.xtpl$/, loader: "@ali/xtemplate-loader" },
    ]
  },
  resolveLoader: {
	root:  path.join(__dirname, "node_modules")
  }
};

common usage

var xtpl = require("./index.xtpl");
var data = {var : "啊"};
var html = xtpl(data);
console.log(html);// => 啊 我编译好了!!! 

other syntax

./index.xtpl

{{var}} 我{{testc(5)}}编译好了!!! 
var xtpl = require("./index.xtpl");
var data = {var : "啊"};
var html = xtpl(data, {
		commands : {
			"testc" : function(scope, option){
            	var n = option.params[0];
            	return n + 1;
        	}
		}
	}););
console.log(html);// => 啊 我6编译好了!!! 

ps

问:怎么保证用户使用的runtime版本和工具使用的xtemplate版本一致呢? 答:工具自动保证,类似handbar-runtime处理方案。

License

MIT (http://www.opensource.org/licenses/mit-license.php)

10.0.9

7 years ago

10.0.8

7 years ago

10.0.6

7 years ago

10.0.5

7 years ago

10.0.4

7 years ago

10.0.0

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.8

7 years ago