Transformercould be used to annotate on a public static methods that works on a given object with or without parameters. For example,
@Transformer public static String format(Number number, String formatStr)
feature.transformer.enabled is set to true (by default
it is true), template author can use Transformer to further process an
@args Date dueDate\n...@dueDate.format("dd/MM/yyyy")
@dueDate.format("dd/MM/yyyy") in the above example will be
S.format(dueDate, "dd/MM/yyyy") in the generated
Note, the above sample code demonstrates a transformer named
format, which is
built into Rythm engine. However when you want to define your own transformer, you
need to use this
Transformer annotation to mark on your methods or classes.
When the annotation is marked on a class, then all public static methods with return
value and at least one parameter will be treated as transformer
You can register them to RythmEngine by
Transformers mechanism is also found in other template engine solutions, but with different names. Freemarker call it built-ins, Velocity called it velocity tools. But none of them are as easy to use as Rythm Transformers
|Modifier and Type||Optional Element and Description|
Indicate whether the expression been transformed should be passed to the transformer function as first or last param
The namespace of the transformer.
Once specified the pattern will be used to match the token to see if transformer extension should be waived or not.
public abstract String value
Default value: "app"
public abstract String waivePattern
public abstract boolean requireTemplate
templateinstance as implicit argument (the first parameter)
public abstract boolean lastParam
Copyright © 2015. All Rights Reserved.