Requirejs Plugin for regularjs
A requirejs/AMD plugin for load Regularjs's template.
Download
1 bower
bower install regularjs-regular --save
2 use git
git clone git@github.com:regularjs/requirejs-regular
Config
require.config({
...
paths : {
"rgl": 'path/to/requirejs-regular/rgl',
//...
}
...
});
Usage
require.config({
paths : {
"rgl": '../../bower_components/regularjs-regular/rgl',
"regularjs": '../../bower_components/regularjs/dist/regular'
}
});
require(['rgl!./foo.html', 'regularjs'], function( tpl, Regular){
var Foo = Regular.extend({
template: tpl
})
new Foo({}).$inject("#app")
});
where in foo.html
{{message}}
Optimizer
With optimizer, after the compiling step. the Regularjs template will be preparsed to ast
__for Example __
the dependency rgl!foo.html
in example above
{{message}}
will be converted to ast like below
;
Optimizer Example see Demo's build.js
License
MITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT