Canjs Mustache

canjs

http://canjs.com/guides/Mustache.html

<script type="text/mustache" id="todosList">
    {{#todos}}
        <li>{{description}}</li>
    {{/todos}}
</script>

Todo.findAll({}, function(todos) {
    document.getElementById('list')
    .appendChild(can.view('todoList', {todos: todos}));
});

What are the 3 magic tags?

  1. {{ }} will HTML-escape the value enclosed inside the tags and write it to the template.
  2. {{{ }}} will write the value enclosed inside the tags directly to the template without escaping it.
  3. {{! }} is a comment that writes nothing to the template.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License