13.3 文本原型注释块:添加代码

JAVASCRIPTCSS模版模式(TEXT不可用)允许在一句特殊的注释语法之间包含代码。当处理模版时,Thymeleaf将自动取消注释:

var x = 23;

/*[+

var msg  = "This is a working application";

+]*/

var f = function() {
    ...

将会当作以下内容执行:

var x = 23;

var msg  = "This is a working application";

var f = function() {
...

你可以在这些注释里包含表达式。它们会被执行:

var x = 23;

/*[+

var msg  = "Hello, " + [[${session.user.name}]];

+]*/

var f = function() {
...

Last updated