ractive-componentify
A versatile browserify transform for ractive components, following the Ractive.js component specification.
Inspired by ractiveify, it lets you compile the component contents of the script and style tags using a language of your choice.
It also generates sourcemaps that map directly to the component original source.
Install
npm install ractive-componentify --save
Configuring the browserify transform
var browserify = ;var componentify = ; var b = ;b;b;
Defining your own compilers
Compilers are defined using the same value of the type attribute of the script and style tags, like this:
var componentify = ; componentifycompilers"text/es6" = { // Your compile code goes here return source: /* compiled source */ map: /* resulting sourcemap */ ;}
You can also return a promise
var componentify = ; componentifycompilers"text/es6" = { // Your compile code goes here return compiler;}
Currently Sourcemaps are only supported in js compilers.
You can also override the default text/javascript
and text/css
compilers.
Requiring components
var Main = ; var app = el: '#main' data: title: 'My App' ;
Partials
You can also import partials in component files. The only requirement is that partial files need to start with an underscore.
{{>mypartial}}
The link, style and script tags are ignored inside partials.