Skip to content

Commit eb37b5e

Browse files
committed
add 'default' and 'math' helpers
add documentation
1 parent 278f8bb commit eb37b5e

14 files changed

Lines changed: 813 additions & 99 deletions

File tree

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
## Handlebars.java Helpers ##
22

3-
Helpers for Handlebars.java.
3+
This library provides various helpers for adding logic to [Handlebars.java](https://github.com/jknack/handlebars.java).
4+
Most of them are basic helpers that can be used as subexpressions in the built-in block helpers of Handlebars.java.
5+
This allows writing the templates in a fluent way.
6+
7+
**Example**
8+
9+
Given the following YAML model:
10+
```yaml
11+
birthYear: 1997
12+
```
13+
and the following template:
14+
15+
```hbs
16+
{{def 'fifteenYear' (math birthYear '+' 15)}}
17+
{{#if (or
18+
(and
19+
(compare (math fifteenYear '%' 4) '==' 0)
20+
(compare (math fifteenYear '%' 100) '!=' 0)
21+
)
22+
(compare (math fifteenYear '%' 400) '==' 0)
23+
)
24+
}}
25+
Your fifteenth anniversary was in a leap year!
26+
{{/if}}
27+
```
28+
The resulting text will be:
29+
```
30+
Your fifteenth anniversary was in a leap year!
31+
```
32+
33+
34+
35+
Please read the **[documentation](http://handlebars-java-helpers.beryx.org)** before using the handlebars-java-helpers library.

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ repositories {
7979
mavenCentral()
8080
}
8181

82-
sourceCompatibility = 1.8
82+
sourceCompatibility = 1.6
8383
group = 'org.beryx'
8484
version = hbsHelpersVersion
8585

@@ -116,17 +116,17 @@ dependencies {
116116
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.20'
117117
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
118118
compile 'com.github.jknack:handlebars:4.0.5'
119-
119+
120120
provided 'com.google.code.findbugs:findbugs-annotations:3.0.1'
121-
121+
122122
testCompile 'org.yaml:snakeyaml:1.17'
123123
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
124124
exclude module: 'groovy-all'
125125
}
126126
testCompile 'cglib:cglib-nodep:3.2.1'
127127
testCompile 'org.objenesis:objenesis:2.2'
128128
testCompile('com.athaydes:spock-reports:1.2.10') { transitive = false}
129-
129+
130130
}
131131

132132
sourceSets.main.compileClasspath += configurations.provided
@@ -348,22 +348,22 @@ gradle.taskGraph.whenReady { taskGraph ->
348348
bintray {
349349
user = project.hasProperty('bintrayUser') ? project.getProperty('bintrayUser') : "unknownUser"
350350
key = project.hasProperty('bintrayKey') ? project.getProperty('bintrayKey') : "unknownKey"
351-
publications = ["handlebars-java-helpers"]
351+
publications = ["hbsHelpers"]
352352
pkg {
353353
repo = 'maven'
354354
name = 'handlebars-java-helpers'
355355
userOrg = 'beryx'
356356
licenses = ['Apache-2.0']
357357
vcsUrl = 'https://github.com/beryx/handlebars-java-helpers.git'
358-
358+
359359
version {
360360
name = hbsHelpersVersion
361361
desc = "Handlebars.java Helpers $hbsHelpersVersion"
362-
released = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
362+
released = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
363363
vcsTag = hbsHelpersVersion
364364
gpg {
365365
sign = true
366366
}
367-
}
367+
}
368368
}
369369
}

doc/docinfo.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Histats.com START (aync)-->
2+
<script type="text/javascript">var _Hasync= _Hasync|| [];
3+
_Hasync.push(['Histats.start', '1,3473102,4,0,0,0,00010000']);
4+
_Hasync.push(['Histats.fasi', '1']);
5+
_Hasync.push(['Histats.track_hits', '']);
6+
(function() {
7+
var hs = document.createElement('script'); hs.type = 'text/javascript'; hs.async = true;
8+
hs.src = ('//s10.histats.com/js15_as.js');
9+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(hs);
10+
})();</script>
11+
<noscript><a href="/" target="_blank"><img src="//sstatic1.histats.com/0.gif?3473102&101" alt="free html hit counter" border="0"></a></noscript>
12+
<!-- Histats.com END -->

doc/getting_started.adoc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
[[getting_started]]
22
= Getting Started
33

4-
== Requirements
5-
TBD
4+
handlebars-java-helpers is available in Maven Central and JCenter.
5+
6+
[subs="attributes",options="nowrap",title="Maven"]
7+
----
8+
&lt;dependency&gt;
9+
&lt;groupId&gt;{project-group}&lt;/groupId&gt;
10+
&lt;artifactId&gt;{project-name}&lt;/artifactId&gt;
11+
&lt;version&gt;{project-version}&lt;/version&gt;
12+
&lt;/dependency&gt;
13+
----
14+
15+
[subs="attributes",options="nowrap",title="Gradle"]
16+
----
17+
compile '{project-group}:{project-name}:{project-version}'
18+
----

0 commit comments

Comments
 (0)