I’ve read about new feature in Haxe 4 : Inline Markup, but I don’t really understand how to use it.
When I simply write var html = <div>Foo</div>; just to avoid messing with simple and double quotes, I get this error : Markup literals must be processed by a macro.
Can anyone explain me more please ?
Thanks in advance
Thanks Alexander for your answer.
Yes I’ve seen that but why for example can’t we use markup literals without a macro ? Here compiler catches that <div> is unterminated : Unterminated markup literal. I think it could be also taken as is without be processed by a macro and if one want to process it, it could. Or maybe have a generic macro process function in haxe.Xml for example ? I don’t know…
class Test {
static function main() {
var s = markupProcessor( <div>Hello</di> );
trace( s );
}
static public macro function markupProcessor(e:haxe.macro.Expr) {
switch e {
case macro @:markup $v:
return macro $v;
default:
}
return macro null;
}
}