Meng Tian
Meng Tian

Reputation: 21

How to check whether the value of a attribute starts with a specific string?

For example, the value of the attribute <greeting> is "Hello, world!".

What I want is to check whether the <greeting> starts with "Hello", if so, apply template <response>.

My string template snippet:

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

Upvotes: 1

Views: 187

Answers (1)

Sam Harwell
Sam Harwell

Reputation: 99889

The expression you're after violates one of the core principles of the strict model-view separation in StringTemplate. No such expression exists by design, so you'll need to place the condition somewhere in your Java code which uses the templates.

Upvotes: 1

Related Questions