【问题标题】:Filtering tags using Rythm template engine使用 Rythm 模板引擎过滤标签
【发布时间】:2015-06-21 08:55:38
【问题描述】:

是否可以过滤Rythm中的标签?

我想允许iffor 等特定标签,同时拒绝所有其他标签(尤其是@{ })。

【问题讨论】:

  • 更正拼写,添加代码标签并链接到 Rythm。

标签: java rythm


【解决方案1】:

目前没有过滤机制。然而,Rythm 提供了一个名为 Dialect 的实用程序,以允许模板作者使用 Rythm 指令的限制集。例如,SimpleRythm 不允许您使用以下指令:

"@extends",
"@section",
"@render",
"@inherited",
"@doLayout",
"@doBody",
"@include",
"@set",
"@get",
"@init",
"@finally",
"@nosim"

虽然BasicRythm 受到更多限制,您不得使用以下任何指令:

"@args",
"@assign",
"@debug",
"@doLayout",
"@doBody",
"@extends",
"@section",
"@render",
"@inherited",
"@i18n",
"@import",
"@include",
"@invoke",
"@locale",
"@set",
"@get",
"@init",
"@finally",
"@expand",
"@exec",
"@macro",
"@compact",
"@nocompact",
"@def ",
"@tag ",
"@return",
"@nosim",
"@verbatim"

为了使用特定的方言,而不是使用

String result = engine.render(...);

使用以下代码:

ITemplate template = engine.getTemplate(SimpleRythm.INSTANCE, ...);
String result = template.render();

暂时没有办法阻止@{...}。请在https://github.com/greenlaw110/rythm/issues 上提交工单以请求配置以禁用 Rythm 模板中的脚本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 1970-01-01
    • 1970-01-01
    • 2013-03-16
    • 2020-02-16
    相关资源
    最近更新 更多