I am working on Ember TodoMVC sample and trying to make the App template compiled : Here's a template example :
<script type="text/x-handlebars" data-template-name="todo-list">
{{#if length}}
<section id="main">
{{#if canToggle}}
{{input type="checkbox" id="toggle-all" checked=allTodos.allAreDone}}
{{/if}}
<ul id="todo-list">
{{#each}}
<li {{bind-attr class="isCompleted:completed isEditing:editing"}}>
{{#if isEditing}}
{{todo-input type="text" class="edit" value=bufferedTitle focus-out="doneEditing" insert-newline="doneEditing" escape-press="cancelEditing"}}
{{else}}
{{input type="checkbox" class="toggle" checked=isCompleted}}
<label {{action "editTodo" on="doubleClick"}}>{{title}}</label>
<button {{action "removeTodo"}} class="destroy"></button>
{{/if}}
</li>
{{/each}}
</ul>
</section>
{{/if}}
</script>
And then in my javascript code :
var source = $("#myapp").html(); // getting the template
var template = Handlebars.compile(source); // compiling the template
var html = template(data); //serving the template as html with data
But template is a function which needs data parameters, So which data parameters needs to be set ?
Thank you!
Aucun commentaire:
Enregistrer un commentaire