Syntaxes.FLUYT.parse("Hello $who").set("who", "world").render(System.out);
$name
Locations can have attributes.
$label(pad="15" pad.fill="."): $name(default="Snippetory")
$fields{
$name(pad="15"pad.fill="."): $value(number="#.###,##" date="long")
}$
Regions allow loops or conditions
void renderFields(Map<String, Object> fields, Template fieldsTpl) {
field.forEach(k, v ->
fieldsTpl
.get("fields")
.set("name", k)
.set("value", v)
.render()
)
}
Regions have attributes like locations.
$products(delimiter="------------\n"){
...
}$
/// start with a triple slash
To keep the template intact there are several syntaxes.
<!-- Syntax:FLUYT_X -->
<nav>
<ul>
<t:menu>
<li><a href="$page(enc='url')">$text</a></li>
</t:menu>
</ul>
</nav>
The tag syntax allowes the IDE to support in closing the tags and keep the overview with code folding...
// Syntax:FLUYT_CC
// $getters{
public $type get$Name$() {
return $name$;
}
// }$
And having valid java code lets the IDE maintain the templates during re-factorings.
SQL module
With the StatementRepository templates produce prepared statements in JDBC
-- $variables{
set :currency = 'EUR';
set :catIds = 17;
-- }$
SELECT products.*
FROM products
LEFT OUTER JOIN prices ON (
products.id = prices.productId
AND prices.currency = :currency
)
WHERE products.id IN (
SELECT prodCat.product.id
FROM prodCat
/*${*/
WHERE prodCat.categoryId IN (:catIds/*delimiter=', '*/)
/*}$*/
)
Having prepared variables makes it easy to test the intact statement, a fluent API gives access to the data.
Statement stmt = new SqlContext()
.uriResolver(UriResolver.resource("org/jproggy/sample"))
.connections(() -> connection)
.getRepository("DbAccessRepo.sql")
.get("statement1");
catIds.forEach(id -> stmt.append("catId", id));
List<Object[]> result = stmt.set("currency", "USD")
.list(SQL.objects());
- The platform is extensible concerning
- A
TemplateWrapper
helps with implementing cross cutting concerns - Groovy integration
- ...
Further information can be found on the homepage or the project blog.