JS Compiler: fix interaction with NHT code
Opened this issue · 6 comments
Please, fix JS Compiler to correctly parse NHT code insertions like as:
div {
span="?[:SomeVariable]" {}
}
Change precedence tpl then js would not work
You have practical example?
If I write such construction:
div {
span="?[:SomeVariable]" {}
}
then I get output:
var Ø5=WAVE.ce('span');Ø5.innerText=[:SomeVariable];
which contains invalid NHT code [:SomeVariable]
.
Also, how exactly I should write laconf code in this case:
@[if (m_IsOwner) {]
<a class='uiSmallButton' href='?[order.Link]'>Order</a>
@[}]
?
I guess the NHT compilation model is such that NHT generates C# template class.
The LJS comilation phase is taking place before NHT/C#, so there is no way you can eval
NHTC# syntax before LJS (laconinc js). In your case I would use the (ctx ) passed into the js function
and use pure js IF. Another way it to compile LJS under NTC ifs
Fixed.
Use double question marks
div {
span="??[:SomeVariable]" {}
}
There is some inconvenience to use the offered decision. To parse my statement correctly I have to wrap it with additional quotes every time:
div {
span="?'?[:SomeVariable]'" {}
}