Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to register template helper in json #16

Closed
carlosanunes opened this issue Jun 22, 2014 · 3 comments
Closed

Unable to register template helper in json #16

carlosanunes opened this issue Jun 22, 2014 · 3 comments

Comments

@carlosanunes
Copy link

Hi,

I seem unable to register a handlebars helper in a json. Although the helper is registered it does not call the specified function, it only prints the "function name".

This is the syntax I am using :

"metalsmith-templates": {
    "engine": "handlebars",
    "helpers" : { "<helper_name>" : "<function_name>" }
}
@carlosanunes
Copy link
Author

Changed a bit the syntax and now I am getting this error :

Metalsmith · Object function_name has no method 'call'

@hced
Copy link

hced commented Oct 1, 2014

I am also very fond of knowing where and how to register Handlebars helpers. I'm using Metalsmith in the CLI fashion.

For instance, I've got these two helpers, which I don't really know where to put (I'm not a progammer):

Handlebars.registerHelper('capitalize', function(title) { return title.capitalize(); });

Handlebars.registerHelper("formatDate", function(datetime) {
if (moment) {
f = DateFormats['long'];
return moment(datetime).format(f);
}
else {
return datetime;
}
});
var DateFormats = {
short: "DD MMMM - YYYY",
long: "MM/DD/YYYY"
};

@ianstormtaylor
Copy link
Contributor

Hey thanks for this sorry for the delay. Now that https://github.com/superwolff has split out this plugin into two separate plugins—layouts and in-place—I'm going to deprecate the metalsmith-templates plugin, so that we can use the simpler ones instead. I'm going to close this PR, but feel free to re-open there!

Added a deprecation notice to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants