Template Syntax
Hix templates support a rich tag syntax for rendering model-based structures. Tags are enclosed in double square brackets [[ ]]
.
Model Tags
[[model.className]]
: Injects the model's class name.
Property Tags (inside [[prop]]
)
[[prop.name]]
: Injects the name of the property[[prop.type]]
: Injects the property type
Control Flow
Loops
[[prop]]
[[prop.type]] [[prop.name]];
[[/prop]]
Optional filters:
[[prop type=bool]]
[[prop ignore=Id]]
Conditionals
[[if prop.type=bool]]
// do something
[[else]]
// do something else
[[/if]]
Functions
Apply transformations to values:
[[upper prop.name]] => MYFIELD
[[lower prop.name]] => myfield
[[snake_case prop.name]] => my_field
Comments
Hix doesn't support comments in template syntax directly yet, but you can use:
// [[prop.name]] is the name of the field
Example Template
public class [[model.className]] {
[[prop]]
[[if prop.type=bool]]
public bool [[prop.name]];
[[else]]
public [[prop.type]] [[prop.name]];
[[/if]]
[[/prop]]
}