edit - there's now a sample Ractive+RequireJS application at https://github.com/RactiveJS/requirejs-ractive/tree/master/sample
Vanhelgen's answer is correct - the text plugin (download from here) allows you to require
any resource, not just AMD modules in .js files, which allows you to keep your templates in a separate file.
So in the second example block of the wiki page, the contents of the templates/main.html
file are available to the code block as the variable mainTemplate
.
Taking it one step further, you can use the Ractive loader plugin alongside the text plugin, and the contents of the html file will be preparsed with Ractive's parser. (This is only really worth doing if you're using the RequireJS optimiser to bundle everything into a single file before deploying your app.)
As an aside, it's best not to overwrite variables like Ractive
, as it can cause some hard-to-debug situations. The convention is to use lowercase variable names for instances, so ractive = new Ractive(...)
rather than Ractive = new Ractive(...)
.