-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
283 lines (252 loc) · 17.9 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Trimou - Trim Your Moustache Templates!</title>
<meta charset="utf-8">
<meta name="description" content="Simple to use and easy to extend Mustache templating engine implementation written in Java.">
<meta name="keywords" content="Java,Mustache,templates,Handlebars,templating engine">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min-3.3.1.css" media="screen">
<link rel="stylesheet" href="css/font-awesome.min.css" media="screen">
<link rel="stylesheet" href="css/sunburst.css" media="screen">
<link rel="stylesheet" href="css/basic.css" media="screen">
<link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="navigation-menu" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#" title="Trimou"><img alt="Brand" src="img/trimou-logo-small.png"></a>
</div>
<div id="menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-lg fa-ship menu-icon"></i>
Releases
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="http://search.maven.org/#search|ga|1|trimou" target="_blank"><i class="fa fa-database"></i> Maven Central Repository</a></li>
<li><a href="https://github.com/trimou/trimou/releases" target="_blank"><i class="fa fa-history"></i> Changelog</a></li>
<li><a href="https://github.com/trimou/trimou/wiki/Roadmap" target="_blank" title="A list of upcoming versions"><i class="fa fa-calendar-check-o"></i> Road Map</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-lg fa-book menu-icon"></i>
Documentation
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="doc/latest.html" target="_blank">Latest (2.3)</a></li>
<li><a href="doc/javadoc/index.html" target="_blank">Latest javadoc</a></li>
<li role="separator" class="divider"></li>
<li><a href="doc/2.2.0.Final/trimou-doc.html" target="_blank">2.2</a></li>
<li><a href="doc/2.1.0.Final/trimou-doc.html" target="_blank">2.1</a></li>
<li><a href="doc/2.0.0.Final/trimou-doc.html" target="_blank">2.0</a></li>
<li><a href="doc/1.8.4.Final/trimou-doc.html" target="_blank">1.8</a></li>
<li><a href="doc/1.7.3.Final/trimou-doc.html" target="_blank">1.7</a></li>
<li><a href="doc/1.6.2.Final/trimou-doc.html" target="_blank">1.6</a></li>
<li><a href="doc/1.5.3.Final/trimou-doc.html" target="_blank">1.5</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-lg fa-plug menu-icon"></i>
Extensions
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="http://trimou.org/doc/latest.html#cdi" target="_blank">CDI</a></li>
<li><a href="http://trimou.org/doc/latest.html#servlets" target="_blank">Servlets</a></li>
<li><a href="http://trimou.org/doc/latest.html#prettytime" target="_blank">PrettyTime</a></li>
<li><a href="http://trimou.org/doc/latest.html#minify" target="_blank">Minify</a></li>
<li><a href="http://trimou.org/doc/latest.html#gson" target="_blank">Gson</a></li>
<li><a href="http://trimou.org/doc/latest.html#spring_mvc" target="_blank">Spring MVC integration</a></li>
<li><a href="http://trimou.org/doc/latest.html#spring-boot" target="_blank">Spring Boot Starter</a></li>
<li><a href="http://trimou.org/doc/latest.html#dropwizard" target="_blank">Dropwizard</a></li>
<li><a href="http://trimou.org/doc/latest.html#el" target="_blank">EL 3.0</a></li>
<li><a href="http://trimou.org/doc/latest.html#json-p" target="_blank">JSON Processing (JSR 353)</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-lg fa-commenting-o menu-icon"></i>
Contribute
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="https://github.com/trimou/trimou" target="_blank"><i class="fa fa-github"></i> Source Code</a></li>
<li><a href="https://github.com/trimou/trimou/issues" target="_blank"><i class="fa fa-bug"></i> Issue Tracker</a></li>
</ul>
</li>
<li>
<div class="badges">
<a href="https://travis-ci.org/trimou/trimou" target="_blank"><img src="https://api.travis-ci.org/trimou/trimou.png" /></a>
</div>
</li>
<li>
<div class="badges">
<a href="https://gitter.im/trimou/trimou" target="_blank"><img style="max-width:100%;" src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter"></a>
</div>
</li>
<li>
<div class="badges">
<a href="https://twitter.com/trimoutemplates" target="_blank"><img style="max-width:100%;" src="https://img.shields.io/twitter/follow/trimoutemplates.svg?style=plastic" alt="Twitter"></a>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="container content">
<div class="row">
<!--div class="col-md-8"-->
<div class="jumbotron">
<h1>Trim Your Templates!</h1>
<p>Trimou is a <a href="https://github.com/mustache" target="_blank">Mustache</a> templating engine implementation written in Java. <strong>Helper API</strong> inspired by <a href="http://handlebarsjs.com/" target="_blank">Handlebars.js</a> is also included. The goal is to provide a <strong>simple to use</strong> and
<strong>easy to extend</strong> templating engine for any Java SE or Java EE application. Trimou is available under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License 2.0</a>.</p>
<p>The most notable advanced features include <a href="http://trimou.org/doc/latest.html#use_template_locator" target="_blank">template caching</a>, <a href="http://trimou.org/doc/latest.html#extend" target="_blank">template inheritance</a>, <a href="http://trimou.org/doc/latest.html#helpers" target="_blank">Helper API</a>, <a href="http://trimou.org/doc/latest.html#how_to_extend" target="_blank">many extension points</a> and ready-to-use extensions out of the box (CDI, Servlets, PrettyTime, Dropwizard, etc.)</p>
</div>
<div>
<a name="get_started"></a>
<h2>Get the latest version <a href="http://search.maven.org/#search%7Cga%7C1%7Ctrimou-core" target="_blank">
<img style="max-width:100%;" src="http://img.shields.io/maven-central/v/org.trimou/trimou-core.svg" alt="Maven Central">
</a></h2>
<p>All the artifacts are available in <a target="_blank" href="http://search.maven.org/#search|ga|1|trimou">the Maven Central Repository</a>:</p>
<pre><code class="xml"><dependency>
<groupId>org.trimou</groupId>
<artifactId>trimou-core</artifactId>
<version>${version.trimou}</version>
</dependency></code></pre>
</div>
<!--/div-->
<!--div class="col-md-4">
<a class="twitter-timeline" href="https://twitter.com/TrimouTemplates" data-widget-id="605738322074476544">Tweets by @TrimouTemplates</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div-->
</div>
<div class="row">
<h2>Get started!</h2>
<ol>
<li><a href="#hello_world">Hello world!</a></li>
<li><a href="#locators">Template locators and caching</a></li>
<li><a href="#helpers">Helpers</a></li>
<li><a href="#inheritance">Template inheritance</a></li>
</ol>
<hr/>
<a name="hello_world"></a>
<h3>Hello world!</h3>
<p>And now for something completely different...</p>
<pre><code class="java">Mustache mustache = MustacheEngineBuilder
.newBuilder()
.build()
.compileMustache("Hello {{this}}!");
System.out.println(mustache.render("world"));</code></pre>
<a href="#get_started"><i class="fa fa-arrow-circle-o-up fa-lg"></i> Up</a>
<hr/>
<a name="locators"></a>
<h3>Template locators and caching</h3>
<p><a href="http://trimou.org/doc/latest.html#template_locator" target="_blank">Template locators</a> automatically locate the template contents for the given template id. So that it’s not necessary to supply the template contents every time the template is compiled. Moreover, if the template cache is enabled (it is by default) the compiled template is automatically put in the cache and no compilation happens the next time the template is requested.</p>
<p>The usual workflow looks like this:</p>
<ol>
<li>Build the engine and add template locators as needed</li>
<li>Hold the reference to the <code>MustacheEngine</code></li>
<li>Whenever the template is needed, obtain a "fresh" instance from the engine</li>
</ol>
<pre><code class="java">
MustacheEngine engine = MustacheEngineBuilder
.newBuilder()
.addTemplateLocator(new FilesystemTemplateLocator(1, "/home/trimou/resources", "txt"))
.build();
String output = engine.getMustache("foo").render(null);</code></pre>
<a href="#get_started"><i class="fa fa-arrow-circle-o-up fa-lg"></i> Up</a>
<hr/>
<a name="helpers"></a>
<h3>Helpers</h3>
<p><strong>Helpers</strong> are de-facto tags which are able to consume multiple parameters and optional hash map.
There are some <a href="http://trimou.org/doc/latest.html#helpers" target="_blank">built-in helpers</a> registered automatically (if, unless, each, etc.).
Trimou also provides <strong>a lot of useful helpers which are not registered automatically</strong>, e.g. <code>ResourceBundleHelper</code>.</p>
<p>Suppose we have the following resource bundle file:</p>
<pre><code class="html">my.message.key=My name is %s!
hello.key.messageformat=Hello {0}!</code></pre>
<p>We can use the <code>ResourceBundleHelper</code> to render messages. First register the helper:</p>
<pre><code class="java">MustacheEngine engine = MustacheEngineBuilder
.newBuilder()
.registerHelper("msg", new ResourceBundleHelper("messages"))
.build();</code></pre>
<p>Now let's create the template:</p>
<pre><code>{{msg "my.message.key" "Martin"}}
{{msg "hello.key.messageformat" "world" format="message"}}</code></pre>
<p>And the output is:</p>
<pre><code class="html">My name is Martin!
Hello world!</code></pre>
<p>Feel free to create <a href="http://trimou.org/doc/latest.html#custom_helpers" target="_blank">your own helper</a>!</p>
<a href="#get_started"><i class="fa fa-arrow-circle-o-up fa-lg"></i> Up</a>
<hr/>
<a name="inheritance"></a>
<h3>Template inheritance</h3>
<p>This useful feature is not supported in the spec. Trimou basically follows the way <a href="https://github.com/spullara/mustache.java" target="_blank">mustache.java</a> implements the template inheritance.</p>
<ul>
<li>In the extended template (parent), the sections to extend are defined - use <code>$</code> to identify such sections.</li>
<li>A section identified with <code><</code> includes the extended template</li>
<li>In the extending template (child), the extending sections are defined - again, use <code>$</code> to identify such sections. Sections to extend may define the default content.</li>
</ul>
<p>The following template with name "super":</p>
<pre><code>{{$header}}
The default header
{{/header}}
In between...
{{$content}}
The default content
{{/content}}</code></pre>
<p>Can be extended in this way:</p>
<pre><code>Hello world!
{{<super}}
{{$header}}
My own header
{{/header}}
Only extending sections are considered...
{{/super}}
Lalala...</code></pre>
<p>And the result is:</p>
<pre><code class="html">Hello world!
My own header
In between...
The default content
Lalala...</code></pre>
<a href="#get_started"><i class="fa fa-arrow-circle-o-up fa-lg"></i> Up</a>
<hr/>
<div class="row footer">
<hr/>
<!--div>
<a href="https://twitter.com/TrimouTemplates" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @TrimouTemplates</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div-->
© 2016 Trimou team
</div>
</div>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-41837896-1']);
_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>
</body>
</html>