Conditional $if
statements
#10994
-
A Google Ai summary said
So I'm assuming that's not valid at all. It would be handy if I don't need another YAML value though. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
I don't think this is currently possible to do in templates. There is already a feature request for this functionality: jgm/doctemplates/issues/29 |
Beta Was this translation helpful? Give feedback.
-
AI is making it up. Your authoritative source is the documentation: |
Beta Was this translation helpful? Give feedback.
-
Somewhat complex, but you could query your metadata and construct a new variable based on that using
This will set the template variable |
Beta Was this translation helpful? Give feedback.
-
See also #3697 -- the discussion there ventures into the idea of allowing a templating language so that e.g. lua templates are optionally saved, and pandoc's lua engine preparses these before pandoc uses them... |
Beta Was this translation helpful? Give feedback.
-
@jgm Ah. I've used JQ before. I generally stick to code that's simple enough to remember and adjust later; my terminal skills are light! (presumably you'd wrap template content with I'll just add it as a YAML tag for now. I only need it for a single page, so a simple scripting option like mustache (as in other issue) would definitely be welcomed with equality etc. I do think it's wise to limit features of Pandoc though, I already find the documentation tricky to pinpoint what I want sometimes. I'm purposefully using Pandoc for a simple website as it's easier to use than, say, https://www.11ty.dev/ or Zola. I just need a way to loop through the compiled files and output a list of posts (I'm sure there's a bash command for that). So yeah, templating for those reasons. |
Beta Was this translation helpful? Give feedback.
-
Actually jq isn't even necessary. This is simpler:
|
Beta Was this translation helpful? Give feedback.
-
One other thing I am struggling with is how to use (a) errors -- href="$css$?v=$css-version$" in the template
Error compiling template "./source/pandoc/template.html" (line 57, column 18):
unexpected " " (b) errors Could not parse '2.5.0' as JSON:
Trailing garbage |
Beta Was this translation helpful? Give feedback.
AI is making it up. Your authoritative source is the documentation:
https://pandoc.org/MANUAL.html#templates