Opened 8 years ago

Last modified 5 years ago

#3825 new task

Start using template strings

Reported by: sanderd17 Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Simulation Keywords:
Cc: Patch:

Description (last modified by Imarok)

JavaScript offers template strings since version spidermonkey 34: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

It's completely standardised in the ES2015 standard, so syntax won't undergo any breaking changes from now on (as per the ES mantra of "don't break the web"). There are certain advantages of using template strings:

  • For simulation XML schema definitions: by including it as one big template string, the XML would keep its new lines and indentation when passed to the Engine. This would allow the engine to show better error messages when there's something wrong in the XML.
  • Different strings with variables get ugly when having a lot of things like "+"/"+" ... These strings get a lot less ugly when written as template strings.

But, as it's new, not all tools support it yet. So in particular:

It would be nice to test this further against the next release.

Change History (4)

comment:1 by elexis, 8 years ago

Milestone: Alpha 21Backlog

Had seen those things in php and shellcode and never liked them (maybe unless you have text across multiple lines). If you want to test it for the release, go ahead and add it somewhere.

If the team agrees to start using them, it should likely be part of the coding convention rather than a ticket.

comment:2 by sanderd17, 8 years ago

It depends on the Spidermonkey upgrade, so it's indeed not for immediately.

But it would certainly help the XML schemas IMO, since the current schemas have no indentation or newlines when stored in the JS variable, so parsers can't mention the lines where the issues happen even if they would want to.

comment:3 by Imarok, 5 years ago

Description: modified (diff)

Sounds like a good feature we should start using

comment:4 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

Note: See TracTickets for help on using tickets.