开发者

How do I use an IF statement in a loop with StringTemplate

This displays nothing:

$Articles:{ $if(i!=1)$ 开发者_StackOverflow社区 display in between articles $endif$ $it.Text

}

This displays as expected

$Articles:{ display in between articles $it.Text

}

Any ideas on how to get this working?


you need to compute all expressions and push into the template. You are clearly filtering, which shoul be done in the model not the view. Please see:

http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

Terence


here, it says that $if tests for the presence of an attribute or evaluates a boolean expr. The only operator allowed is !(NOT),
so maybe you can define a boolean variable = (i!=1) and use it in the $if statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜