Using Standard Template Helpers with handlebar/mustache templates

438 views
Skip to first unread message

Gareth Foote

unread,
Nov 15, 2012, 11:18:04 AM11/15/12
to doc...@googlegroups.com
Hi there,

I'm unsure as to how I go about using the Standard Template Helpers (in this case 'getFilesAtPath') when using a template engine other than eco. 

Here is the example from the Quick Start guide on the DocPad site that I would like to achieve using Mustache:

<% for post in @getFilesAtPath("posts").toJSON(): %> <a href="<%= post.url %>"><%= post.title %></a><br/> <% end %>

In mustache I can't see a way of getting the call to the template helper into the curly braces. This doesn't work:
{{#getFilesAtPath("posts")}}

Any help would be appreciated.

Thanks,
Gareth

Benjamin Lupton

unread,
Nov 18, 2012, 7:30:50 AM11/18/12
to
Hey Gareth,

To use template helpers with moustache/handlebars, you actually need to define their support manually - there's info on how to do this for the getBlocks helper in the README here: https://github.com/docpad/docpad-plugin-handlebars

I've made an issue here on the plugin to see if we can make it so support for template helpers are included by default: https://github.com/docpad/docpad-plugin-handlebars/issues/2

Alternatively you could do that one template up in a different templating engine...

Will keep track on this, but my availability is quite limited as I'm currently focusing on improving the documentation and skeletons right now. If it's urgent, you could purchase some premium support via http://bevry.me/support and I'll be able to attend to it quicker.

Hope that helps mate, keep me updated.

Gareth Foote

unread,
Nov 18, 2012, 3:09:18 PM11/18/12
to doc...@googlegroups.com
Hi Benjamin,

Thanks for your response. I managed to miss that part of the README. For the time being I will use this method.

Thanks,
Gareth
Reply all
Reply to author
Forward
0 new messages