Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if conditionals in pandoc templates depending on value of a variable

In pandoc, you can see if you have a variable or not ($if(something)$ put $something$ $endif$), but I want to act depending on its value. Something like:

$if(lang)=='en'$ Hello $else$ Aloha $endif$

Is it possible? In Pandoc Manual I don't see nothing

like image 790
somenxavier Avatar asked Jul 30 '17 20:07

somenxavier


1 Answers

That would have been inside Pandoc Manual if there was such a feature and according to this pandoc-discuss it is not possible with pandoc.

What it is possible, is to define some more general variables that will contain things you want to change.

For example if you want to use the English language, set a variable lang.en and check it with $if(lang.en)$. If you want another language then unset lang.en and set lang.fr and use it like this:

$if(lang.en)$
Hello
$else$
Aloha
$endif$

$if(lang.fr)$
Bonjour
$else$
Aloha
$endif$
like image 145
Christos Lytras Avatar answered Oct 05 '22 09:10

Christos Lytras