Ractify
Upgrading from v0.4.x to v0.5.x
Replace require('ractive/build/ractive.runtime')
with require('ractive/ractive.runtime')
v0.4.x
I've decided to remove some "magic." Namely:
- Ractify no longer uses
Ractive.extend
require('ractify')
no longer includes the ractive runtime (it throws an error and will be removed in future versions)
ractify still parses Ractive components, but it just returns a plain javascript object with template
and css
properties (and whatever <script>
code is in the Ractive component). See this issue
See test input and output for an example.
Upgrading from v0.3.x to v0.4.x
- replace
var Ractive = require('ractify')
withvar Ractive = require('ractive/build/ractive.runtime')
- For components, replace
var Foo = require('./foo.ract')
with:
var Ractive = var Foo = Ractive
Upgrading from <v0.3.0 to v0.4.x
- replace
require('ractify')
withrequire('ractive/build/ractive.runtime')
- replace
new Ractive({ template:require('./foo.ract'), ... })
withnew Ractive({ template:require('./foo.ract').template, ... })
Installation
Ractify does not install Ractive on its own, you must do so yourself (this allows you to update Ractive without an update to ractify).
Example:
npm install --save ractify
npm install --save ractive@0.4.0
Usage / Examples
Browserify API usage:
var browserify = var ractify = var bundle = bundle
In your Client-side JavaScript, require('ractive/build/ractive.runtime')
and it'll import the runtime-only version of
ractive. require
a .ract
file, and it will return a plain javascript object with template
and (if defined) css
parameters:
var Ractive = var foo = template:template el: document data: ...
This structure can be passed into Ractive.extend
to automatically build Ractive components:
var Ractive = var Foo = Ractivevar foo = el: document data: ...
Extract partials by inspecting the template
property:
var foo = if footemplatepartials // foo.template.main has the main template // foo.template.partials has the partial templates
Commandline Browserify usage:
$ browserify -t ractify main.js > bundle.js
If you want to use different file extension, e.g. .html
, you can use extension
option:
var browserify = ;var ractify = ; var bundle = ;bundle;
$ browserify -t [ ractify --extension html ] main.js > bundle.js
License
Open source software under the zlib license.