While trying to template some LaTeX, which uses curly braces to enclose directive parameters, I noticed that templates would consume the literal braces, rather than inserting them as required. For example, say if I want to template:
\section{<SECTION_NAME>}
...my immediate thought was to use tmpl("\\section{{{ section_name }}}", section_name = "foo"). This however is rendered as:
\sectionfoo
I found no combination of characters that allowed me to surround a templated expression with curly braces, without interposing whitespace. @wahani suggested the following workarounds:
While trying to template some LaTeX, which uses curly braces to enclose directive parameters, I noticed that templates would consume the literal braces, rather than inserting them as required. For example, say if I want to template:
...my immediate thought was to use
tmpl("\\section{{{ section_name }}}", section_name = "foo")
. This however is rendered as:I found no combination of characters that allowed me to surround a templated expression with curly braces, without interposing whitespace. @wahani suggested the following workarounds:
Option 1:
Option 2:
Option 3: