2

suppose I have a template

"{man} likes to do {do}"

I create the engine

 ST engine = new ST(template, '{', '}');

The result with do set to sports and no man in the model is:

"likes to do sports"

but I'd prefer it to stay unresolved, that is

"{man} likes to do sports"

Can this be done in StringTemplate 4?

Parobay
  • 2,549
  • 3
  • 24
  • 36

1 Answers1

0

You can use an if-else construct in the template file to check if a parameter to the template is provided.

Example: {if (man)}{man}{else}\{man\}{endif}, I am not sure if this is the correct way to escape delimiters though.

The Cat
  • 2,375
  • 6
  • 25
  • 37