Histone is an open source template engine for Java, JavaScript and PHP

Histone is a powerful and flexible template engine used to produce HTML code as well as any other text formats. Histone can be run on the client (JavaScript) as well as server (Java, PHP) side without modifying your templates. Its built-in extensions API allows you to add your own methods and attributes that are specific to your project. The resulting templates have clean and intuitive syntax, you can store them in either original or "optimized" form that will not require parsing, depending on whether or not you need an extra performance.

What is Histone?

Histone is a powerful and flexible template engine that is suitable for producing HTML code and other text formats. To put it simple, it can convert JSON data into HTML on a wide array of platforms.

Why use Histone?

What’s wrong with other engines?

Before we started our own engine, we did a research on the existing products to understand their pros and cons. We considered only popular template engines with significant user base. We also focused on engines that were implemented in at least two out of three needed languages (Java, JavaScript, PHP).

Google Closure templates






Ideas behind Histone

After considering existing tools our team decided to write a new engine that will have the advantages of Closure and Mustache while fixing shortcomings that were critical for us. Histone had to meet the following requirements:

— Cross-platform templatesAll Histone implementations should use the same syntax. That way, we can use the same templates on the server and the client side.

— Familiar and intuitive syntax.  Every template instruction is delimited by {{ and }}. The rest is ignored by the parses and makes it into the resulting document as is.

— No embedded code in templatesMost template engines permit embedding code that will be executed directly from the template. Usually, only the language of the engine implementation is supported, so in order to use the same template with another implementation you will also have to rewrite the code. Because of that we did not enable code embedding in Histone.

— Template engine is easily expandableRegardless of the engine’s implementation in use its API allows adding a new method or attribute.

— One source file to rule them all. JSON is the universal format for Histone. Histone supports all data types that are provided by the JSON format. It doesn’t matter what data types are supported by your project’s language, Histone’s template language provides you with all the necessary data types supported by JSON, making it a perfect tool to transform JSON documents.

— Templates are platform-awareThe template always considers the platform it is being used on. E.g., when run in the browser, the template adapts to the screen resolution and window size. When run on the server, the template may use request headers and adapts to the OS of the server.

— Cross-platform, easy to portJavaScript, Java and PHP implementations are available out of the box. Histone doesn’t rely on external libraries and has well-structured code which makes it easy to write a C++, Ruby, Objective-C or ActionScript implementation of the engine.

— FastUnlike Google Closure Templates, Histone does not translate the template to the language that is used by the specific implementation. Instead, it has a tool that can recompile the template so that the actual parsing (the most time-consuming operation) will be avoided. Part of the template that does not rely on external functions, attributes and variables, is also executed at this point.

Histone and Sublime Text 2


Now you can use Histone template language syntax highlighting in wonderful Sublime Text 2 editor. Just download and install Sublime Text 2 plugin for Histone template engine, using instructions which is located on this page.Read more »

Histone - live playground


Good news! Now you can easily try Histone in our new application, that allows you to run template processing right in your favorite web - browser. Just open an application using the link below, put template code in the editor that is placed on the left side of the application window and press "Execute". Template processing result will be printed on the right side of the application window. To change the resultRead more »

Histone 1.0-M1 (beta)


We’re proud to announce you the release of the first milestone of version 1.0. This milestone is the first one and it’s going to be the base for the future release, that will follow after intensive testing phase and bug fixing. Syntax basics as well as developer’s API won’t be affected tremendously in the future milestones of the version 1.0. If you’re interested in this project roadmap, please spend someRead more »

Project blog


We’d like to take this opportunity to introduce Histone project’s blog. We’re going to use this blog to post an information about the new releases, important changes in the functionality and lots of examples that shows how to use Histone in your web - applications. You can learn more about the project in our documentation. We have a bug - tracking system that you can use to let us knowRead more »