Skip to content

Comment on Show HN: Moon – 3kb JavaScript UI compiler

Comments

How are variables in "<p>{text}</p>" replaced? Is the security of it just an implementation detail left to the programmer who use it? Safe way would be finding the P and then doing p.textContent = data. But how do you find element by value efficiently? Or do you just to text replace?

kbrOP

Your views are compiled down to JavaScript beforehand. Your example would be compiled to something like:

  m2.textContent = instance.text;
Use Moon.compile(template) to get a better idea of outputs.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.