Joachim,Am 17.04.2019 um 07:56 schrieb jtuchel@objektfabrik.de:
Norbert,
thanks for answering. I had tried the {{{ }}} option. In case of LaTeX, this is not so easy, however, because {{{ and }}} are completely valid syntactical elements of LaTeX.
It seems like you can replace {{ and }} in Mustache, but not {{{ and }}}. At least it didn't work when I tried. Using '{{{=### ###=}}} ' in my MustacheTemplate would leave text like '###myObject.printString###' unchanged in the resulting text instead of replacing it with the text representation of myObject.
So what I tried last and what gave me quite some mileage on the way to a sulotion was to use
\catcode to replace & with ; in my LaTeX file for the Column separator problem
{{=## to make sure I can fill in my table rows with ; as column separator.
Thus my Mustache-Template looks like this (excerpt):
% redefine Mustache-Insertion syntax {{=## ##=}}
\catcode`\;=4 % redefine ; for & to allow non-escaped column-separators in \tabular
...
\begin{tabular}{ccp{6.0cm}rrr}
##myObject.asLatexTableRows## % This is where & is needed for LaTeX to separate table columns, but Mustache would replace the with the html entity &
\end{tabular}
This is a bit hacky, and as I wrote, also still presents problems, because if any of the Strings being inserted using Mustache contains an &, there will be an & in the .tex file, which will lead to a LaTeX error.
So, essentially, what I am most likely looking for is a way to replace {{{ and }}} in Mustache to make sure the $&'s will remain untouched in my inserted text...
Sorry for asking the wrong question, I was so glad how far I'd gotten with what I did that I didn't see the forest between all the trees.
So my real question is: how can I replace {{{ in Mustache with something that will not irritate LaTeX?
Any ideas?
Sure ;) In Mustache {{ and }} are the default delimiters. Every addtional character is a modifier. So {{{ is actuall a start delimiter {{ with a { as modifier. So what you can do is to change the delimiter but leave the { modifier like so '{{=<% %>=}} <%{ value %>}' asMustacheTemplate value: { #value -> '&' } asDictionary So {{ is the start delimiter, = is the modifier to change the delimiters. We set them to <% and %>. If you want to have unescaped strings you keep using the { on the new delimiter which turns out to be <%{ and %>}.
I���m not sure the { should not be nested. Need to think about it. It might should be like <%{ }%>.