norcalli / ractiveify

Browserify transform for ractive components (and by extension templates) which allows for compilation of embedded scripts and styles!
9 stars 1 forks source link

Precompile templates #4

Closed victorwpbastos closed 9 years ago

victorwpbastos commented 9 years ago

How to only precompile templates? I'm using like this:

// view
var SomeView = Ractive.extend({
    template: require('templates/someTemplate.tpl')
});
// browserify
...
ractiveify.extensions.push('tpl');
bundler.transform(ractiveify);
...

but it's not working. In console I get template mismatch errors!

norcalli commented 9 years ago

require('template.tpl') returns an object {template: "..."} already, so you are doing more than you need to. As you could see from the examples on the readme, you can just do Ractive.extend(require('template.tpl')).

victorwpbastos commented 9 years ago

In my case I want to use Ractive as if it was a Backbone.View:

var SomeView = Ractive.extend({
    template: require('templates/someTemplate.tpl'),
    onconfig: function() {},
    data: {},
    someMethod: function() {}
});

that's why I need only to precompile the templates.

norcalli commented 9 years ago
var SomeView = Ractive.extend({
    template: require('templates/someTemplate.tpl').template,
    onconfig: function() {},
    data: {},
    someMethod: function() {}
});

should work.