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 )
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:
- Syntax colouring of certain editors may be broken, tested editors:
- Vim: works well with some syntax libraries
- GtkSourceView (gedit and related): should be fixed in the next release: https://mail.gnome.org/archives/commits-list/2016-January/msg08480.html
- ...
- Tools that parse JS (like our internationalisation script) may have problems with it
It would be nice to test this further against the next release.
Change History (4)
comment:1 by , 8 years ago
Milestone: | Alpha 21 → Backlog |
---|
comment:2 by , 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 , 5 years ago
Description: | modified (diff) |
---|
Sounds like a good feature we should start using
comment:4 by , 5 years ago
Component: | UI & Simulation → Simulation |
---|
Move tickets to Simulation
as UI & Simulation
got some sub components.
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.