![]() |
||
|
||
![]() |
These are the built-ins that normally you should not use, but in exceptional situations (debugging, advanced macros) they can be useful. If you need to use these in your normal page templates, you may revisit the data model so you don't need to use these.
Returns a SimpleNumber which contains the same value as the original variable, but uses java.lang.Type for the internal representation of the value. This is useful if a method is overloaded, or if a TemplateModel unwrapper has problem with automatically choosing the suitable java.lang.* type.
This built-in evaluates a string as an FTL expression. For example "1+2"?eval returns number 3.
This built-in interprets a string as a FTL template, and returns a TemplateTransformModel that - when applied to any block - executes the template just as if it was included at that point. Example:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
The output:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
As you can see, inlineTemplate is a TemplateTransformModel that, when executed, runs the template that was generated on-the-fly using the interpret. Further, the transform will append whatever its body is (in our case "def") to the output of the inline template.
You can also apply this built-in to a two-element sequence. In this case the first element of the sequence is the template source, and the second element is a name for the inline template. It can be useful to give an explicit name to the inline template for debugging purposes. So, you could have written:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
as well in the above template. Note that giving the inline template a name has no immediate effect - it is only useful as an extra bit of information if you get an error report.
These built-ins check the type of a variable, and returns true or false depending on the type. The list of is_... built-ins:
Built-in |
Returns true if the value is a ... |
---|---|
is_string |
string |
is_number |
number |
is_boolean |
boolean |
is_date |
date (all types: date-only, time-only and date-time) |
is_method |
method |
is_transform |
transform |
is_macro |
macro |
is_hash |
hash |
is_hash_ex |
extended hash (i.e. supports ?keys and ?values) |
is_sequence |
sequence |
is_collection |
collection |
is_enumerable |
sequence or collection |
is_indexable |
sequence |
is_directive |
macro or transform |
is_node |
node |
This built-in returns the namespace (i.e. the ``gate'' hash to the namespace) associated with a macro variable. You can use it with macros only.
This is to create a variable of a certain TemplateModel implementation.
On the left side of ? you specify a string, the full-qualified class name of a TemplateModel implementation. The result is a method variable that calls the constructor, and returns the new variable.
Example:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
For more information about how the constructor parameters are unwrapped and how overloaded constructor is chosen, read: Programmer's Guide/Miscellaneous/Bean wrapper
![]() |
||
|
||
![]() |
![]() |
|
Page generated: 2006-03-15 13:49:01 GMT | FreeMarker Manual -- For FreeMarker 2.3.6 |