GeezerVison is showing jknack.github.io — {{ Handlebars.java }} - Prototype your web sites with Handlebars.java!
Prototype your web sites with Handlebars.java!
In this section you will learn to prototype web sites using the Handlebars.java Server!
Download
Just click here for download the file.
Usage
java -jar handlebars-proto-1.0.0.jar [-option value]
The Java Runtime Environment must be installed. In case you don't have one installed already, you can download and install from here.
Options:
- -dir (-d): set the template directory. Required.
- -contentType (-ct): set the content's type header, default is:
text/html
- -context (-c): set the web context's path, default is:
/
- -port (-p): set the port's number, default is:
6780
- -prefix (-px): set the template's prefix, default is:
/
- -suffix (-sx): set the template's suffix, default is:
.hbs
Starting the server
java -jar handlebars-proto-1.0.0.jar -d site
site/home.hbs:
<html>
<body>
<ul>
{{#blogs}}
<li>{{name}}</li>
{{/blogs}}
</ul>
</body>
</html>
Open a browser and type:
http://localhost:6780/home.hbs
So, is that all? No, the next section teach you how to add data to your templates.
Data Sets
- as JSON
site/home.json
{
"blogs": [
{
"name":"Handlebars.java"
}, {
"name":"Handlebars.js"
}, {
"name":"Mustache"
}
]
}
- as YAML
site/home.yml
blogs:
- name: Handlebars.java
- name: Handlebars.js
- name: Mustache
By default the data file must match the template name and must be in the same directory.
You can specify a different data set by using the
dataparameter in the url.
http://localhost:6780/home.hbs?data=path/home2
Thedataparameter is a file path without a file extension.
Error reporting
Handlebars.java errors are reported through a very nice HTML page.
Conclusion
The Handlebars.java Server is a nice tool for prototyping web sites.
Data can be provided in two very user friendly formats and it has an excellent error reporting tool, these two features make ideal Handlebars.java for web designers.
Cool, isn't?
Want to contribute?
- Fork the project on Github.
- Create an issue or fix one from the issues list.
- Share your ideas or ask questions on mailing list - don't hesitate to write a reply - that helps us improve javadocs/FAQ.
- If you miss a particular feature - browse or ask on the mailing list - don't hesitate to write a reply, show us a sample code and describe the problem.
- Write a blog post about how you use or extend Handlebars.java.
- Please suggest changes to javadoc/exception messages when you find something unclear.
- If you have problems with documentation, find it non intuitive or hard to follow - let us know about it, we'll try to make it better according to your suggestions. Any constructive critique is greatly appreciated. Don't forget that this is an open source project developed and documented in spare time.
Thank you, for reading the Handlebars.java blog.