Freemarker replacement (square brackets) syntax, freemarker square brackets
Note:
This feature is available only after FreeMarker 2.3.4.
FreeMarker supports a replacement syntax. [And] is used in the instructions and comments of FreeMarker to replace <and>. For example:
Call predefined commands: [# list animals as being]... [/# list]
Call custom commands: [@ myMacro/]
Note: [# -- the comment --]
To use this syntax to replace the default syntax, you must use this syntax to use ftl commands from the template. If you do not know what the ftl command is, use [# ftl] to start the template. Remember to put this command at the beginning of the file (except the space before it ). For example, the last example in the example below describes how to use this replace syntax.
[#ftl]<p>We have these animals:<table border=1><tr><th>Name<th>Price[#list animals as being]<tr><td>[#if being.size = "large"]<b>[/#if]${being.name}[#if being.size = "large"]</b>[/#if]<td>${being.price} Euros[/#list]</table>
This replacement syntax (square brackets) and default syntax (angle brackets) are mutually exclusive in a template. That is to say, the entire template either uses both the replacement syntax and the default syntax. If the template uses the replacement syntax, parts such as <# if...> are regarded as static text rather than FTL labels. Similarly, if the template uses the default syntax, such as [# if...] will also be regarded as static text rather than FTL labels.
If you use [# ftl...] (... indicates the list of optional parameters. Of course, only [# ftl] s is used to start the file. Then, the file uses the Replace (square brackets) syntax. If you start with <# ftl...>, the file uses the normal (angle brackets) syntax. If there are no ftl commands in the file, the programmer can decide which syntax to use by configuring FreeMarker (the programmer can refer to Configuration. setTagSyntax (int) in the API documentation. However, programmers may use the default configuration. FreeMarker 2.3.x Default Configuration
Use regular syntax. The default configuration in version 2.4 will be automatically checked, that is, the first FreeMarker tag determines the syntax format (it can be arbitrary, not just ftl ).
Freemarker Replacement Problem with parentheses in the Variable
Why are you doing this? It is recommended that you take a look at the Java Development specifications.
FreeMarker's Chinese API, some mail 614008251 @ 163com
Sent. Please check it !~
Directory
FreeMarker manual ...................................... ........................................ ............................ 1
Used for FreeMarker 2.3.18 ..................................... ........................................ .............. 1
Directory ....................................... ........................................ ........................................ .......... 2
Preface ....................................... ........................................ ........................................ .......... 7
What is FreeMarker? ........................................ ........................................ ................. 7
What should we read? ........................................ ........................................ .......... 7
Document conventions ...................................... ........................................ ..................................... 8
Contact us ...................................... ........................................ ..................................... 8
Some notes ...................................... ........................................ ..................................... 8
The first part of the Template Development guide ................................... ........................................ ........................ 9
Chapter 1 Introduction to Template Development ................................... ........................................ .................... 9
1.1 Introduction ...................................... ........................................ .............................. 9
1.2 template + Data Model = output ................................. ....... remaining full text>