简体   繁体   English

节奏模板引擎自定义标签加载

[英]Rythm template engine custom tags loading

I have custom Rythm template tag (sayHi.html) which I want to call from parent template (index.html): 我有自定义的Rythm模板标记(sayHi.html),我想从父模板(index.html)调用它:

In sayHi.html: 在sayHi.html中:

Hi there!

In index.html: 在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. 我发现Rythm模板引擎(v0.9)的默认行为是它试图在当前应用程序文件夹中查找自定义模板文件。 Thus if I have web project running in Tomcat the path would be /TOMCAT_HOME/bin/sayHi.html 因此,如果我有在Tomcat中运行的Web项目,则路径为/TOMCAT_HOME/bin/sayHi.html

How could I tell Rythm to load custom tags from another path (eg /WEB-INF/tags)? 如何告诉Rythm从另一个路径(例如/ WEB-INF / tags)加载自定义标签?

you can ask Rythm to load tags from anywhere: 您可以要求Rythm从任何位置加载标签:

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

See source code here 在这里查看源代码

You can also init Rythm.engine (or RythmEngine instance managed by yourself): 您还可以初始化Rythm.engine (或由您自己管理的RythmEngine实例):

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 请从rythm网站下载最新的发行包
  3. The rythm document is not up to date. 节奏文件不是最新的。 However you can get some new information from Play-Rythm documentation: 但是,您可以从Play-Rythm文档中获得一些新信息:

Updates 更新

Rythm has deprecated the tag concept, as now you can call any template as a "tag". Rythm已弃用标签概念,因为现在您可以将任何模板称为“标签”。 See http://rythmengine.org/doc/template_guide.md#invoke_template 参见http://rythmengine.org/doc/template_guide.md#invoke_template

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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