hans / obsidian-citation-plugin

Obsidian plugin which integrates your academic reference manager with the Obsidian editor. Search your references from within Obsidian and automatically create and reference literature notes for papers and books.
MIT License
1.04k stars 76 forks source link

if statement #263

Open JensjJ8200 opened 5 months ago

JensjJ8200 commented 5 months ago

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 commented 5 months ago

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.