1

There's grunt-contrib-handlebars and grunt-grunt-contrib-haml, but I need the combination of the two. Say I have a "hamlbars" template like the following:

%div
  {{ name }}

I need this to be precompiled into JavaScript just as grunt-contrib-handlebars would do to

<div>
  {{ name }}
</div>

There's also grunt-hamlbars but I could not get it to work. It however only compiles hamlbars to handlebars, I need to take a step further and precompile the handlebars.

Perhaps I'm taking the wrong approach? Should I just stick with normal HTML and handlebars? Is there a seamless way to compile HAML into HTML then precompile as a handlebars file, all using Grunt?

MusikAnimal
  • 2,286
  • 2
  • 22
  • 28
  • You could pre compile the Handlebars and then take that output and compile the HAML. However since there is already a Grunt task for HamlBars I would recommend using that. Can you post a link to your Grunt file so we can try and figure out why grunt-hamlbars is not working? – Noah Huppert Nov 04 '14 at 23:56
  • @NoahHuppert how could I precompile Handlebars _then_ compile the HAML? The precompilation will result in JavaScript which Ruby cannot interpret – MusikAnimal Nov 05 '14 at 02:09
  • I am not sure what you mean. If you are using Handlebars then the `{{foo}}` should be replaced with `foo`(Or whatever value). So then when you compile the Haml the `{{}}` will be gone. – Noah Huppert Nov 05 '14 at 02:11
  • @NoahHuppert No, I'm referring to _precompilation_, not runtime compilation. Precompiling means the markup and everything is already converted to a big JavaScript function which can be directly executed at runtime, passing `foo` into that function. Like so: http://handlebarsjs.com/precompilation.html – MusikAnimal Nov 05 '14 at 02:20
  • I'm having the same issue. Would it not be possible to use the HAML api to compile the HAML first to HTML, and then doing the precompilation task as usual? – Tails Nov 21 '14 at 15:38

0 Answers0