aumcode / nfx

C# Server UNISTACK framework [MOVED]
https://github.com/agnicore/nfx
Other
391 stars 93 forks source link

JS Compiler: fix interaction with NHT code #51

Open vlapchenko opened 7 years ago

vlapchenko commented 7 years ago

Please, fix JS Compiler to correctly parse NHT code insertions like as:

div {
  span="?[:SomeVariable]" {}
}
itadapter commented 7 years ago

Change precedence tpl then js would not work

You have practical example?

vlapchenko commented 7 years ago

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].

vlapchenko commented 7 years ago

Also, how exactly I should write laconf code in this case:

@[if (m_IsOwner) {]
  <a class='uiSmallButton' href='?[order.Link]'>Order</a>
@[}]

?

itadapter commented 7 years ago

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

OlegPanagushin commented 7 years ago

Fixed. Use double question marks

div {
  span="??[:SomeVariable]" {}
}
vlapchenko commented 7 years ago

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]'" {}
}