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

if statement #263

Open
JensjJ8200 opened this issue Jan 16, 2024 · 1 comment
Open

if statement #263

JensjJ8200 opened this issue Jan 16, 2024 · 1 comment

Comments

@JensjJ8200
Copy link

Hello

I am trying to setup an if statement in the templater using handlebars, but it seems like there is no way to compare variables.

e.g. I want to add a text, if a itemtype is a book and do not add that text if the itemtype is not a book.

pesudocode.

if itemtype= book then

@orionpilot
Copy link

I forget where I found the right format but I do have an if statement in my citations template, though it just checks if the comment field is empty or not. If not empty, then the comment is pasted in the callout. If empty, then No comment is inserted. Code:

> [!Note] JabRef Comment
> {{#if entry.data.fields.comment}}
> {{entry.data.fields.comment}}
> {{else}}
> No comment
> {{/if}}

A quick Google search shows that it may not be directly possible to compare variables like you want without using/creating a "helper" (which I don't know more about unfortunately). However, if there is a way to distinguish the books and not books in this true or false manner, maybe this code can help.

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