Feature Request: Add Logic to Handlebars
Would it be possible to add comparisons for note variables? It would be really useful, for example, to be able to choose the number of topics to generate, like so:
---
topic_count:
label: Number of topics (up to 5)
type: number
---
{{#if topic_count>=1}}
# Topic 1
{{/if}}
{{#if topic_count>=2}}
# Topic 2
{{/if}}
{{#if topic_count>=3}}
# Topic 3
{{/if}}
Revisiting this much later, this post on SO seems to have a good way to add logical operators into the template
Thanks @ImperialSquid, I'm a little occupied these days. I'd encourage you to raise a pull request since you've figured out how to implement this to some extent.
I have like none of the dev environment set up for this kinda work since I do python and R most days but I'll see what I can do if I get a chunk of time 😅👌
Hey @nishantwrp, I've got a bit more experience in js since posting this and remembered I posted the issue a while back, was just wondering if you'd still accept a pr to add this feature?
Also do you have any ideas about a name for the handler? I was thinking {{#compare X > Y}} but it's your plugin so up to you!
Hey @ImperialSquid, yes sure please raise a pull request. compare looks good.
Implemented in https://github.com/joplin/plugin-templates/pull/79. This feature will go out in the next release.