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

Add (string) comparison as helper function #56

Closed
Engwer opened this issue Jan 27, 2022 · 2 comments · Fixed by #79
Closed

Add (string) comparison as helper function #56

Engwer opened this issue Jan 27, 2022 · 2 comments · Fixed by #79
Assignees

Comments

@Engwer
Copy link

Engwer commented Jan 27, 2022

Would it be possible, to include a custom helper function for Handlebars? I want to create templates based on the input upon creation. However, simple true/false evaluation doesn't do the trick for me. There are already solutions available, e.g. https://stackoverflow.com/questions/10736907/handlebars-js-else-if but I guess, that has to be included at the plugin level. In that question, one solution is to create an ifEquals function via:

Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
    return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
});

and then call it in the template via:

{{#ifEquals project "project 1"}}
     Project 1 selected
   {{else ifEquals project "project 2"}}
     Project 2 selected
{{/ifEquals}}

Additionally, I also want to change the template_title based on a variable or change the template_notebook

@nishantwrp
Copy link
Collaborator

Hi @Engwer, you are welcome to contribute to this plugin and send a pull request. Your idea seems useful & interesting.

@nishantwrp
Copy link
Collaborator

Implemented in #79. This feature will go out in the next release.

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