Reputation: 45
Haxe takes some templates to bin
folder when it compiles. It process templates, replacing variables in it ::WIN_WIDTH::
with values 640
. It can also take your custom templates like so:
<template path="your/template.txt" rename="tmpl.txt"/>
I would like to know is there any way to place your own variables ::myvar::
in those templates?
EDIT
http://old.haxe.org/doc/cross/template - Unfortunately, that article only explains how to execute haxe.Template
class instances. In the end you will get the string (your processed template).
What I want is to add my custom placeholders to default haxe templates, such as OpenFL Android project templates. I need Haxe to process it's templates WITH my own placeholders and outputs it in the bin
folder, as usually does.
Upvotes: 0
Views: 304
Reputation: 430
I had to figure it out the hard way, but it turns out that the <setenv> tag really works as advertised.
In project.xml:
<setenv name="MY_VAR" value="612" />
In template.txt:
::if ENV_MY_VAR::
The value of MY_VAR is ::ENV_MY_VAR::.
::else::
MY_VAR is not defined.
::end::
You could also define it as "myvar", but then you'd have to use "ENV_myvar" in template.txt.
Upvotes: 2
Reputation: 12
http://old.haxe.org/doc/cross/template this explain everything about templates, how to use variables and things like if and foreach.
Upvotes: 0