regularjs 's requirejs plugin.
JavaScript
Switch branches/tags
Clone or download
Latest commit b0605f0 Feb 2, 2015
Permalink
Failed to load latest commit information.
demo 0.3.0 version Feb 2, 2015
src 0.3.0 version Feb 2, 2015
.gitignore first commit Oct 18, 2014
README.md add License Oct 18, 2014
bower.json 0.3.0 version Feb 2, 2015
component.json 0.3.0-pre Jan 4, 2015
gulpfile.js 0.3.0 version Feb 2, 2015
package.json 0.3.0 version Feb 2, 2015
rgl.js 0.3.0 version Feb 2, 2015

README.md

#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

3 directly download rgl.js

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

<h2>{{message}}</h2>

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

<h2>{{message}}</h2>

will be converted to ast like below

define("rgl!foo.html", function(){ return [{"type":"element","tag":"h2","attrs":[],"children":[{"type":"expression","body":"_c_._sg_('message', _d_['message'])","constant":false,"setbody":"_c_._ss_('message',_p_,_d_, '=')"}]}] 
});

Optimizer Example see Demo's build.js

License

MITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT