Templates4J extensions for XML


Лицензия

Лицензия

Категории

Категории

Сеть
Группа

Группа

net.evilengineers.templates4j
Идентификатор

Идентификатор

templates4j-extension-xml
Последняя версия

Последняя версия

1.1.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

Templates4J extensions for XML
Ссылка на сайт

Ссылка на сайт

http://github.com/danishdynamite/templates4j

Скачать templates4j-extension-xml

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.evilengineers.templates4j/templates4j-extension-xml/ -->
<dependency>
    <groupId>net.evilengineers.templates4j</groupId>
    <artifactId>templates4j-extension-xml</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.evilengineers.templates4j/templates4j-extension-xml/
implementation 'net.evilengineers.templates4j:templates4j-extension-xml:1.1.2'
// https://jarcasting.com/artifacts/net.evilengineers.templates4j/templates4j-extension-xml/
implementation ("net.evilengineers.templates4j:templates4j-extension-xml:1.1.2")
'net.evilengineers.templates4j:templates4j-extension-xml:jar:1.1.2'
<dependency org="net.evilengineers.templates4j" name="templates4j-extension-xml" rev="1.1.2">
  <artifact name="templates4j-extension-xml" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.evilengineers.templates4j', module='templates4j-extension-xml', version='1.1.2')
)
libraryDependencies += "net.evilengineers.templates4j" % "templates4j-extension-xml" % "1.1.2"
[net.evilengineers.templates4j/templates4j-extension-xml "1.1.2"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
net.evilengineers.templates4j : templates4j-core jar 1.1.2

Модули Проекта

Данный проект не имеет модулей.

Extensible template engine for Java

Based upon StringTemplate4, this engine extends it with some very useful features making it applicable for a wider range of templating needs.

It aims to be backwards compatible with ST4-grammar.

User Functions

Since 1.0.0

Often you'll find yourself needing to navigate your model in ways that the template engine does not support natively. This is especially true for ST4, so I've introduced a way to supply user-defined functions that are callable from the template itself. These are called in the same manner as the few built-in functions (strlen, trunc, etc..), but they can accept multiple arguments, each of which can be an expression itself.

Let's say you would like to iterate over a list of objects present somewhere in a DOM-based model, you could do this by executing an XPath-query from your user-function which you'd call from the template like this:

<xpath(model, {//book/author[id='xxx']/parent::chapters}) : outputChapter()>

where model is your DOM model, xpath is your user-function, outputChapter is a another template and { ... } is an anonymous template evaluating to the XPath expression for the query.

Multi-character delimiters

Since 1.0.1

The engine uses a start- and end-delimiter to locate the expressions in your template. Previously, these were limited to a single character, but that has now been generalized so you can use strings of two or more characters as delimiters as needed. This allows you to more easily select delimiters that wont conflict with your template content, making the use of backslash-escaping unnecessary resulting in more readable templates.

To use, just specify delimiters "<#", "#>" in your .stg files, or manually supply them to the constructor of the STGroup or subclasses thereof.

Usage

<dependency>
    <groupId>net.evilengineers.templates4j</groupId>
    <artifactId>templates4j</artifactId>
    <version>1.0.0</version>
</dependency>

The artifact is released in the OSS Sonatype repository:

<repository>
    <id>sonatype-nexus</id>
    <url>http://oss.sonatype.org/content/repositories/releases/</url>
</repository>

History

This project could not have existed if it wasn't for the nice work by the authors of StringTemplate4, but as the features I found necessary in my work were not accepted and because there seems to be a general demand for them, I forked the project and extended it myself. The new projectname is to avoid confusion and possible conflict with the original engine.

The templates4j-core sub-project started its life as a fork of StringTemplate4 ver. 4.0.8 code. The templates4j-mvn-plugin sub-project was written from scratch.

All are covered by a BSD-license.

Версии библиотеки

Версия
1.1.2
1.1.1
1.1.0