【问题标题】:Concatenating a variable with other text using Rythm使用 Rythm 将变量与其他文本连接起来
【发布时间】:2015-09-29 03:19:31
【问题描述】:

我正在使用 Rythm 模板引擎。我有一个变量,我想将它与其他没有空格的文本“连接”起来。我不知道如何分隔变量名和周围的文本 - Rythm 尝试将变量名和额外文本解析为单个表达式。

这是一个例子:

@args String who
Hello @whoextra

http://fiddle.rythmengine.org 上尝试时出现以下错误:

org.rythmengine.exception.CompileException: whoextra cannot be resolved to a variable

如果“谁”的值为“世界”,我要打印的是:

Hello Worldextra

我可以通过以下方式实现:

@args String who
Hello @who.raw()extra

但它似乎有点冗长,尤其是如果我在很多地方使用它。

有没有更好的方法来分隔我在 Rythm 中的表达?

【问题讨论】:

    标签: java template-engine templating rythm


    【解决方案1】:

    使用()分隔:

    @args String who
    Hello @(who)extra
    

    有关 Rythm 模板中的表达式的更多信息,请查看http://rythmengine.org/doc/template_guide.md#expression

    【讨论】:

      猜你喜欢
      • 2014-12-13
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-21
      相关资源
      最近更新 更多