Ant flaka: declare variable with dynamic name
I'm using ant with flaka.
How can I declare a variable with dynamic name (retrieved from ano开发者_如何学编程ther variable)?
I would like to do something like that:
<fl:let>
#{varname} = value
</fl:let>
however, i think it's illegal.
How can i do that?
thanks!
second anwser :
your question is not clear to me :
#{variablename} = value
would overwrite an existing variable variablename, so my second guess is with "based on" you meant something like :
<project xmlns:fl="antlib:it.haefelinger.flaka">
<fl:let>
varname = 'foo'
; declare variable based on other variable
#{varname}bar = 'whatever'
</fl:let>
<fl:echo>
#{varname}
#{foobar}
</fl:echo>
</project>
output :
[fl:echo] foo
[fl:echo] whatever
first answer :
Here's the FAQ entry from the official Ant FAQ solved with Flaka :
<project xmlns:fl="antlib:it.haefelinger.flaka">
<fl:install-property-handler />
<property name="foo" value="foo.value" />
<property name="var" value="foo" />
<echo> #{${var}} = foo.value </echo>
</project>
精彩评论