[ 2 posts ]

Julian Applebaum

  • Username: japplebaum
  • Joined: Sun Apr 22, 2012 12:29 pm
  • Posts: 1
  • GitHub: japplebaum
  • Gists: japplebaum
  • Offline
  • Profile

Handlebars Templates in Gallery Module

Post Posted: Sun Apr 22, 2012 12:44 pm
+0-
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.

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Handlebars Templates in Gallery Module

Post Posted: Mon Apr 30, 2012 7:16 am
+0-
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
  [ 2 posts ]
Display posts from previous:  Sort by  
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