Closed jimmyye closed 10 years ago
Or partial as attr value:
<div rel="popover"
data-html="true"
data-content="{{>profile}}">
...
</div>
You can creat new Ractive({...})
without el
and call .toHTML()
. See http://docs.ractivejs.org/latest/ractive-tohtml
Sure. Though I think the .compile
way is more like others and more compact to use and reuse (other than ractive.reset
).
How about "partial as attr value"? Will this be implemented in the future?
Ractive is more than string parser, so not quite the same, but if you like:
Ractive.compile = function(template){
var parsed = Ractive.parse(template)
return function( context ) {
return new Ractive({
template: parsed,
data: context
}).toHTML()
}
}
var source = $("#template").html();
var template = Ractive.compile(source);
var context = {...}
var html = template(context);
How about "partial as attr value"? Will this be implemented in the future?
Seems reasonable that that should work.
Thanks. Looking forward to it. :)
@jimmyye it looks like partials in attributes now works in edge. @Rich-Harris was that a byproduct of VirtualDom refactor?
Tried it, it works! Thanks. :)
Sometimes I just want the html and don't want to new a Ractive.