Reputation: 135
My eyes struck Ractive.js and I want to test it with Web2py. Web2py however uses also {{ }} as the templating characters. Ractive uses these characters also. I have already a lot of Web2py apps, so changing the {{ }} markers in Ractive is the easiest for me. Can this be done?
Yes it can :
var ractive = new Ractive({
el: whatever,
template: myTemplate,
data: {
greeting: 'Hello',
greeted: 'world',
triple: '<strong>This is a triple-stache</strong>'
},
delimiters: [ '[[', ']]' ],
tripleDelimiters: [ '[[[', ']]]' ]
});
Upvotes: 1
Views: 327
Reputation: 15319
In web2py code you can change the delimiters easily like so:
response.delimiters = ['{%', '%}']
So in the template you can have something like:
<body>
{%web2py code%}
<p>Along with</p>
{{ember/angular/whatever code}}
</body>
I'd say changing the delimiters in web2py is easier, just do a find & replace across all your existing template files and you'll never have to think about it again.
Upvotes: 1
Reputation: 304
If you put the templates in a separate file and load it, e.g. with jQuery, you don't even need to change the delimiters.
$.get("{{=URL('static','templates/hello.html')}}", function(template) {
var ractive = new Ractive({
el: 'container',
template: template,
data: { name: 'world' },
});
});
because, I think, the template script is not in the scope of web2py.
Upvotes: 0