Create a file called
index.html and paste in the following:
Now, open the page in a browser. You should see a 'Hello, world!' message. If you open the console and type
ractive.set('name', 'Jim') the text will update.
That's it - you're in business!
- You could pass in a template string as the
templateoption, rather than the ID of a script tag containing the template. In that case, if your template is more than a couple of lines you'll probably want to keep it in a separate file and load it (e.g. with
$.ajax, if you're using jQuery)
- As your app grows in complexity, you'll want to keep your application code (i.e. the bit that calls
new Ractive()) in a separate file.
- Work your way through the tutorials to become a Ractive master.