In a StringTemplate how to temporarily suppress automatic indentation? Suppose a template:
fooTemplate() ::= <<
I want this to be indented normally.
# I do not want this line to be indented.
>>
So you can understand the motivation. I am generating C-lang code and I do not want the preprocessor instructions to be indented. e.g.
#if
To be clear the fooTemplate is not the only template.
It is called by other templates (which may nest several levels deep).
Introducing a special character into the template to temporarily disable indentation would be acceptable.
fooTemplate() ::= <<
I want this to be indented normally.
<\u0008># I do not want this line to be indented.
>>
I see that indentation is actually applied by the 'AutoIndentWriter' https://github.com/antlr/stringtemplate4/blob/master/doc/indent.md I implemented my own 'SemiAutoIndentWriter' which looks for a magic character (\b in my case) in the stream. When seen the magic character sets a 'suppressIndent' switch which causes indentation to be suppressed.
Note that the '<\b>' is not a recognized special character by ST4 but '' is recognized.