2 - Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 - Use of this source code is governed by a BSD-style license that can be
4 - found in the LICENSE file.
9 <script src="handlebars-1.0.0.beta.6.js"></script>
12 <script id="hello-world-template" type="text/x-handlebars-template">
14 <h1>Hello, {{thing}}!</h1>
19 var source = document.getElementById('hello-world-template').innerHTML;
20 templates['hello'] = Handlebars.compile(source);
22 // Set up message event handler:
23 window.addEventListener('message', function(event) {
24 var command = event.data.command;
25 var name = event.data.name || 'hello';
28 event.source.postMessage({
30 html: templates[name](event.data.context)
34 // You could imagine additional functionality. For instance:
37 // templates[event.data.name] = Handlebars.compile(event.data.source);
38 // event.source.postMessage({name: name, success: true}, event.origin);