HxDTL is a Haxe implementation of Django Template Language.
Current release: HxDtl 0.1.1. Be aware of the changes to the API - it's not stable and will be modified in future releases.
You can also explore Roadmap to see the upcoming release details.
$ haxelib install hxdtl
$ git clone https://github.com/ajukraine/hxdtl.git
$ cd hxdtl
$ git submodule update --init
$ haxelib install mlib
$ haxe install.hxml
Create template from string and render it:
import hxdtl.Template;
var tpl = new Template("
{% if Year > 2012 %}
We have survived!
{% else %}
Hey, {{ friend }}, are we dead?
{% endif %}
");
var data = { Year: 2013, friend: "Billy" };
trace(tpl.render(data));
Get template from file system and render it:
import hxdtl.Template;
import hxdtl.Environment;
var env = new Environment({
path: "path/to/templates",
useCache: true
});
var tpl = env.getTemplate("some_template.dtl");
trace(tpl.render({ Year: 2013, friend: "Billy" }));