如何检查属性的值是否以特定字符串开头?

时间:2013-01-04 15:46:22

标签: antlr3 stringtemplate

例如,属性<greeting>的值为“Hello,world!”。

我想要检查<greeting>是否以“Hello”开头,如果是,请应用模板<response>

我的字符串模板代码段:

<if(/*do not know how to write the condition here*/)><greeting:response()><endif>

1 个答案:

答案 0 :(得分:1)

您所遵循的表达式违反了StringTemplate中严格模型 - 视图分离的核心原则之一。 by design 不存在这样的表达式,因此您需要将条件放在使用模板的Java代码中的某个位置。