haxe.Template: How to add custom variables to use in a template?

Is it possible to add custom variables somewhere (project.xml?) so that they can be used later in a template?

For example, html5 template for index.html has this line:


And the value for APP_TITLE is somehow obtained from prject.xml line

<meta title=“My App Title” … />

So I would like to be able to define my variable somehow in a project and then use it in a template like ::MY_VARIABLE::. Is it possible?

As I understand it, anything with <define/> or <set/> in project.xml is automatically made available to templates in Lime/OpenFL projects. I guess that SET_ is added to the beginning of the name, to help avoid conflicts.

So, if you define something like this…

<define name="MY_VARIABLE" value="123"/>

…you can use it like this in a template:


1 Like

There’s a bit of documentation for that here: XML Format
Note that it will be converted to uppercase when you use it in the template. So if you use <set name="deploydomain" value="yourdomain.com" /> you must access it using ::SET_DEPLOYDOMAIN:: in the template.


@joshtynjala @Confidant thanks, guys! This is exactly what I needed :slight_smile: Both set and define work as expected, thanks!

For other persons coming across this post, note that we’re in OpenFL land here. Regular Haxe template stuff is documented here: Template - Haxe - The Cross-platform Toolkit

Note: I edited that “XML Format” link now to point to the newest domain.

1 Like

Somehow I never realized this, even though it’s been that way for the better part of a decade. I’ve updated the documentation.