I have custom Rythm template tag (sayHi.html) which I want to call from parent template (index.html):

In sayHi.html:

Hi there!

In index.html:

<html>
    <head></head>
    <body>@sayHi()</body>
</html>

I have found out that default behaviour of Rythm template engine (v0.9) is that it tries to find custom template file in current application folder. Thus if I have web project running in Tomcat the path would be /TOMCAT_HOME/bin/sayHi.html

How could I tell Rythm to load custom tags from another path (e.g. /WEB-INF/tags)?

有帮助吗?

解决方案

you can ask Rythm to load tags from anywhere:

Rythm.engine.loadTags(new File("/WEB-INF/tags"));

See source code here

You can also init Rythm.engine (or RythmEngine instance managed by yourself):

Properties conf = new Properties();
conf.put("rythm.tag.root", "/WEB-INF/tags");
Rythm.engine.init(properties); // use Rythm managed engine instance
myEngine = new RythmEngine(conf); // manage rythm engine instance by yourself

Note

  1. Please be aware of this issue since you are not using it with play
  2. Please download latest distribution package from rythm website
  3. The rythm document is not up to date. However you can get some new information from Play-Rythm documentation:

Updates

Rythm has deprecated the tag concept, as now you can call any template as a "tag". See http://rythmengine.org/doc/template_guide.md#invoke_template

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top