obsidian-citation-plugin icon indicating copy to clipboard operation
obsidian-citation-plugin copied to clipboard

if statement

Open JensjJ8200 opened this issue 1 year ago • 1 comments

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

JensjJ8200 avatar Jan 16 '24 09:01 JensjJ8200

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.

orionpilot avatar Jan 16 '24 16:01 orionpilot