Skip to content

Commit a96398a

Browse files
back2doskLabz
authored andcommitted
Interpolate attributes and add test. (#27)
1 parent 64bf295 commit a96398a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/lib/react/ReactMacro.hx

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ class ReactMacro
517517
case Regular(name, value):
518518
neededAttrs.remove(name.value);
519519
var expr = value.getString()
520-
.map(function (s) return macro $v{replaceEntities(s, value.pos)})
520+
.map(function (s) return haxe.macro.MacroStringTools.formatString(replaceEntities(s, value.pos), value.pos))
521521
.orUse(value);
522522

523523
switch (name.value)

test/src/ReactMacroTest.hx

+9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ class ReactMacroTest
116116
// TODO: further check; should fail at compile time atm
117117
}
118118

119+
@Test
120+
public function interpolate_attributes()
121+
{
122+
var answer = "42";
123+
var e = jsx('<input name="question" value="the answer is $42" />');
124+
Assert.areEqual(e.props.value, 'the answer is $42');
125+
// TODO: further check; should fail at compile time atm
126+
}
127+
119128
@Test
120129
public function fragments()
121130
{

0 commit comments

Comments
 (0)