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

Creating a helper with path string parameter #1154

Closed
MuyBien opened this issue Dec 14, 2015 · 2 comments
Closed

Creating a helper with path string parameter #1154

MuyBien opened this issue Dec 14, 2015 · 2 comments

Comments

@MuyBien
Copy link

MuyBien commented Dec 14, 2015

Hi!
I want to create a helper to make translations. In my application, messages key are dotted. For example generic.message.success. So I made the translation helper

 {{translation generic.message.success}}

But generic.message.success is not in the passed JSON. It's a general string. How can I tell the helper to not try to get this string as a JSON member?

Handlebars.registerHelper('translation', function(key) {
    var translation = translate(key);
    return new Handlebars.SafeString( translation );
});

Thanks!

@kpdecker
Copy link
Collaborator

You'll have to pass this in as a string {{translation 'generic.message.success}}`

@MuyBien
Copy link
Author

MuyBien commented Dec 15, 2015

OK simple...
Thanks!

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

No branches or pull requests

2 participants