0

I'm researching a means of using Mustache templating for the view engine in CQ5, which uses Sling. I'm looking for some advise if anyone has already had experience going into this.

I need to use a template format that can be shared between front and back end when required. So mustache is ideal, however, other options may be applicable, such as handlebars.

I have found a git repo for "sling-scripting-mustache" which I am looking into but it lacks any kind of documentation. I will be giving it a try nonetheless.

Would appreciate any thoughts and guidance :)

David
  • 357
  • 1
  • 4
  • 13
  • offtopic, but make sure mustache is your best bet, people often realize they need something that allows for a little more logic, in this case handlebars is a great option. – j_mcnally Apr 18 '13 at 20:03
  • Agreed, I would love to start down that path with handlebars. My problem might come later tho as I will have to find similar solutions for .Net, php, and other environments. Mustache seems to have solutions for those, but I haven't found the same solutions for handlebars. – David Apr 18 '13 at 20:11
  • well handlebars should be languge agnostic as it is run on the client not the server. – j_mcnally Apr 18 '13 at 20:28

3 Answers3

1

Handlebars has been in CQ since 5.6:

The handlebars javascript library was originally added to CQ in 5.6.0 for other purposes. The java version of handlebars is included in AEM 6.0, and in a featurepack for 5.6.1 that contains the Social Component Framework (SCF) (source)

You can write Mustache templates and render them with Handlebars:

Mustache templates are compatible with Handlebars, so you can take a Mustache template, import it into Handlebars, and start taking advantage of the extra Handlebars features (source)

There's some more info here.

Alasdair McLeay
  • 2,572
  • 4
  • 27
  • 50
0

my workflow is usually to compile handlebars or mustache outside of the language pipeline with something like grunt and then include it as a seperate js file.

Now if you are actually trying to do server side templating thats a different issue. Not sure how well handlebars works as a server side template but mustache does for sure.

j_mcnally
  • 6,928
  • 2
  • 31
  • 46
0

The code in the repo (https://github.com/lykorian/sling-scripting-mustache) builds a OSGI bundle with the scripting engine information embedded in its metadata.

Based on what I can see in the pom file, you should install the dependencies:

mvn -Pinstall-dependencies install 

And then build and install the actual bundle by installing it in the OSGI console or running maven (check the pom for the default values):

mvn -Plocal-author install

Once that is installed, the scripting engine should be installed and it should recognize *. mustache files.

Disclaimer: I haven't tested this, these are just my thoughts based on what is in the code and in the pom file. Hope it helps!

ilikeorangutans
  • 1,753
  • 1
  • 11
  • 14