forked from thymeleaf/thymeleaf.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whatsnew11.html
executable file
·368 lines (286 loc) · 13.9 KB
/
whatsnew11.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>What's new in Thymeleaf 1.1 - Thymeleaf: java XML/XHTML/HTML5 template engine</title>
<link rel="stylesheet" type="text/css" media="all" href="css/thymeleaf.css" />
<link rel="shortcut icon" href="http://www.thymeleaf.org/favicon.ico" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{lang:'en', parsetags:'explicit'}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1276954-9']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript" src="sh/scripts/shCore.js"></script>
<script type="text/javascript" src="sh/scripts/shBrushXml.js"></script>
<script type="text/javascript" src="sh/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="sh/scripts/shBrushPlain.js"></script>
<link href="sh/styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="sh/styles/shThemeThymeleaf.css" rel="stylesheet" type="text/css" />
</head>
<body lang="en" dir="ltr">
<div id="page">
<div id="menu">
<ul>
<li><a href="index.html" title="Home">Home</a></li>
<li><a href="features.html" title="Features">Features</a></li>
<li><a href="download.html" title="Download">Download</a></li>
<li><a href="documentation.html" title="Documentation">Documentation</a></li>
<li><a href="ecosystem.html" title="Ecosystem">Ecosystem</a></li>
<li><a href="http://forum.thymeleaf.org" title="User Forum">User Forum</a></li>
<li><a href="issuetracking.html" title="Issue Tracking">Issue Tracking</a></li>
</ul>
</div>
<div id="header">
<a href="index.html" title="Thymeleaf home"><img src="images/thymeleaflogonameverysmall.png" class="logo" alt="Thymeleaf Template Engine"/></a>
</div>
<div id="breadcrumb">
<a href="index.html">thymeleaf</a>
::
<a href="documentation.html">documentation</a>
::
<span class="current">what's new in thymeleaf 1.1</span>
</div>
<div id="content">
<h1>What's new in Thymeleaf 1.1</h1>
<h2>A new expression system: the <i>Standard Expressions</i></h2>
<p>
The old <i>value expression</i> system had a series of limitations, especially
regarding to operators to be applied between expressions. In Thymeleaf 1.1 this system
is substituted in both the Standard and SpringStandard dialects
by a new <i>Standard Expression</i> system, which builds on the
previous one and keeps all of its syntax — so that all your templates still
work alright — and adds the following new features:
</p>
<ul>
<li>Numeric literals: <kbd>1</kbd>, <kbd>32</kbd>, <kbd>42.3</kbd>, <kbd>11.34</kbd>, etc.</li>
<li>Unary operators: <kbd>!</kbd> (boolean negation), <kbd>-</kbd> (numeric minus sign)</li>
<li>String operators: <kbd>+</kbd> (String concatenation)</li>
<li>Numeric binary operators and comparators: <kbd>+</kbd>, <kbd>-</kbd>, <kbd>*</kbd>,
<kbd>/</kbd>, <kbd>%</kbd>, <kbd>></kbd>, <kbd><</kbd>, <kbd>>=</kbd>,<kbd><=</kbd></li>
<li>Boolean binary operators: <kbd>and</kbd>, <kbd>or</kbd></li>
<li>Equality checks: <kbd>==</kbd>, <kbd>!=</kbd></li>
</ul>
<p>
For example, now you can concatenate Strings easily in your expressions, like:
</p>
<script type="syntaxhighlighter" class="brush:html;gutter:false"><![CDATA[
<p th:text="#{title.username} + ': ' + ${user.name}">
]]></script>
<h2>No more Value Processors</h2>
<p>
Thymeleaf 1.0 defined three types of <i>processors</i>: <i>attribute processors</i>,
<i>tag processors</i> and <i>value processors</i>. The latter type, value processors,
were defined as utility objects that executed common logic needed to process
expressions, usually called from attribute or tag processors.
</p>
<p>
This resulted in code similar to this in order to execute an expression from an
attribute value:
</p>
<script type="syntaxhighlighter" class="brush:java"><![CDATA[
final StandardValueProcessor valueProcessor =
arguments.getConfiguration().getValueProcessorByClass(this, StandardValueProcessor.class);
final Value value =
StandardSyntax.parseValue(attributeValue, valueProcessor, arguments, templateResolution);
final String result =
(String) valueProcessor.getValue(arguments, templateResolution, value);
]]></script>
<p>
Thymeleaf 1.1 completely removes the concept of <i>value processor</i> from its API, so that
it allows each dialect to implement expression resolution in the way preferred by its
developers.
</p>
<p>
For example, the <i>Standard</i> and <i>SpringStandard</i> dialects now implement
the resolution of <i>Standard Expressions</i> using the <kbd>StandardExpressionProcessor</kbd> class,
so that all the code above can now be written in a much more concise way:
</p>
<script type="syntaxhighlighter" class="brush:java"><![CDATA[
final String result =
(String) StandardExpressionProcessor.processExpression(arguments, templateResolution, attributeValue);
]]></script>
<h2>New <kbd>th:substituteby</kbd> attribute in the standard dialects</h2>
<p>
Thymeleaf 1.1 adds a new attribute to both the Standard and SpringStandard dialects
called <kbd>th:substituteby</kbd>, which works very similarly to the already
existing <kbd>th:include</kbd> for including a fragment from an external template,
but actually substitutes the host tag by the fragment's, instead of only substituting
its contents — which is what <kbd>th:include</kbd> does.
</p>
<p>
In order to see the differences between these tags, the following fragment:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
<footer th:fragment="copy">
© 2011 The Good Thymes Virtual Grocery
</footer>
]]></script>
<p>
Referenced in your template with both a <kbd>th:include</kbd> and a <kbd>th:substituteby</kbd>:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
<body>
...
<div th:include="footer :: copy"></div>
<div th:substituteby="footer :: copy"></div>
...
</body>
]]></script>
<p>
The results will be slightly different, because <kbd>th:include</kbd> will only
copy the fragment's contents whereas <kbd>th:substituteby</kbd> will actually
replace the host tag by the whole fragment:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
<body>
...
<div>
© 2011 The Good Thymes Virtual Grocery
</div>
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
...
</body>
]]></script>
<h2>New XHTML DTDs for the standard dialects</h2>
<p>
The new <kbd>th:substituteby</kbd> attribute requires a change in the existing
Thymeleaf DTDs (those specified with a <kbd>DOCTYPE SYSTEM</kbd> clause), in order
to include this new attribute and allow its validation.
</p>
<p>
New versions of the DTDs for the Standard and SpringStandard dialects
have been created, so that the old <kbd>DOCTYPE</kbd> declarations:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-1.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-transitional-thymeleaf-1.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-frameset-thymeleaf-1.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-1.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-transitional-thymeleaf-spring3-1.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-frameset-thymeleaf-spring3-1.dtd">
]]></script>
<p>
Can now be substituted by new versions containing the new attribute:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-2.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-transitional-thymeleaf-2.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-frameset-thymeleaf-2.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-2.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-transitional-thymeleaf-spring3-2.dtd">
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-frameset-thymeleaf-spring3-2.dtd">
]]></script>
<h2>New date utility functions</h2>
<p>
Thymeleaf 1.1 adds new functions to the <kbd>#dates</kbd> and <kbd>#calendars</kbd>
utility function objects, which can be used in variable expressions as usual:
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
#dates.hour(now)
#dates.minute(now)
#dates.second(now)
#dates.millisecond(now)
]]></script>
<p>
<i>Since 1.1.2, also:</i>
</p>
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
#dates.createNow()
#dates.createToday()
#dates.create(year,month,day)
#dates.create(year,month,day,hour,minute)
#dates.create(year,month,day,hour,minute,second)
#dates.create(year,month,day,hour,minute,second,millisecond)
]]></script>
<h2>Changes in condition evaluation</h2>
<p>
Condition evaluation —used in <kbd>th:if</kbd> or <kbd>th:unless</kbd> attributes, for
example— changes a bit in Thymeleaf 1.1 so that the Strings
<kbd>"false"</kbd>, <kbd>"no"</kbd> and <kbd>"off"</kbd> now evaluate as
<b>false</b>, instead of <i>true</i> as they did before (Thymeleaf 1.0 evaluated
as <i>true</i> any non-null String).
</p>
<h2>Performance optimization</h2>
<p>
When a template is stored into the cache, Thymeleaf 1.1 now scans its whole DOM tree
in order to determine which nodes —and also entire trees—
are <i>not executable</i> (because no attribute or tag processor can be applied to them),
and marks those DOM nodes so that they are skipped when actually processing the template.
</p>
<p>
This improves performance by allowing the engine to focus only on those nodes that
trigger real execution logic once it retrieves a template from the cache.
</p>
<h2>Fixed HTML entity processing</h2>
<p>
Thymeleaf 1.1 fixes a behaviour in version 1.0 regarding HTML entities
(<kbd>&nbsp;</kbd>, <kbd>&pound;</kbd>, <kbd>&aacute;</kbd>, etc.)
that made the engine raise an
exception like this:
</p>
<script type="syntaxhighlighter" class="brush:plain;gutter:false"><![CDATA[
The entity "nbsp" was referenced, but not declared.
]]></script>
<p>
...in the following cases:
</p>
<ul>
<li>When <kbd>th:utext</kbd> was used for writing a String containing
one of such entities.</li>
<li>In HTML5 templates, every time an HTML entity was used.</li>
</ul>
<p>
Thymeleaf 1.1 fixes this so that not only the presence of these entities
does not cause an error, but also they are preserved as they are
(this is, in <i>escaped</i> form) in output.
</p>
<h2>Modified LEGACYHTML5 mode (since 1.1.2)</h2>
<p>
For performance and reliability reasons, the <kbd>LEGACYHTML5</kbd> mode now uses
<b>nekoHTML 1.9.15</b> or newer as an auxiliary library instead of <b>htmlcleaner</b>,
which was used in previous versions.
</p>
<h2>Dart inlining mode (since 1.1.2)</h2>
<p>
Thymeleaf 1.1.2 adds a new "<kbd>dart</kbd>" inlining mode to its Standard Dialects
(besides <kbd>text</kbd> and <kbd>javascript</kbd>) which allows you to inline your data
in your Dart scripts in the same way as you can currently do with JavaScript..
</p>
<h2>Minor modifications and bug fixing</h2>
<p>
Of course, many minor modifications and bug fixes have been applied too. In order to know
more, <a href="download.html">have a look at the changelogs</a>.
</p>
</div>
<div id="footer">
<div id="googleplus">
<div id="plusone-div" class="plusone"></div>
<script type="text/javascript">
gapi.plusone.render('plusone-div',{"size": "small", "count": "true", "href": "http://www.thymeleaf.org"});
</script>
</div>
<div id="twitter">
<a href="http://twitter.com/thymeleaf" class="twitter-follow-button" data-show-count="false">Follow @thymeleaf</a>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
</div>
<div id="copy">
Copyright © The <a href="team.html">THYMELEAF Team</a>. See <a href="documentation.html">applicable licenses</a>.
</div>
</div>
</div>
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
</body>
</html>