简体   繁体   中英

Filtering tags using Rythm template engine

Is it possible to filter tags in Rythm ?

I want to allow specific tags like if and for while denying all other tags (especially @{ } ).

At the moment no filtering mechanism. However Rythm provides a utility called Dialect to allow template author to use a limit set of Rythm directives. For example, SimpleRythm does NOT allow you to use the following directives:

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

While BasicRythm is more restricted and you are not allow to use anyone of the following directives:

"@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"

In order to use specific dialect, instead of using

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

Use the following code:

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

There is no way to prevent @{...} for the moment. Please submit a ticket on https://github.com/greenlaw110/rythm/issues to request a configuration to disable scripting in Rythm template

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM