| Page 1 of 1 | [ 2 posts ] |
Julian Applebaum
|
What's the best way to include Handlebars template code in a module definition? The
Code: <script type = "text/x-template"> <!-- template code --> </script> trick doesn't seem appropriate appropriate, but I'd also like to avoid directly coding the template in JS. |
|
That's a great question. You're right that sourcing the template from the HTML does not make much sense.
I think the simplest way would be to put the template string your JavaScript module and use the Handlebar's `compile()` method: http://yuilibrary.com/yui/docs/handleba ... -templates If you wanted to get fancier, you could look at keeping your template separate from your JavaScript module by precompiling a source template file into a separate JavaScript file which your module could then require: http://yuilibrary.com/yui/docs/handleba ... -templates |
| Page 1 of 1 | [ 2 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group