Syntax sensitive and highlighting source code editor for template code wanted
Open, LowestPublic

Description

Writing Mediawiki template code is tedious and error prone for all but the most simple cases (e.g. as soon you start to add some logic to a template).
Example: https://de.wikipedia.org/w/index.php?title=Vorlage:Denkmalliste_%C3%96sterreich_Tabellenzeile&action=edit

Current problems:

  • spaces and line breaks in template code are partly propagated to the transclusion of the template and will eventually break the generated wiki-code. This is especially true in templates generating tables, having their own critical handling of spaces and line breaks. Prettyprinting the code ist almost impossible and readability of the code is a nightmare.
  • there are no variables, so code often has to be duplicated
  • a lot of curly braces (2 for the parser functions and 3 for the argument): {{#if: {{ {{PAGENAME}}{{{arg1|}}}}}}}. Makes it rather difficult to get the correct matching braces.
  • there are interferences between template and table syntax (e.g. regarding the pipe)
  • errors in heavy used templates can break a lot of pages
  • replacing template code by lua IMHO is not the solution, as we do not have that many lua programmers. And for private Mediawiki installations lua might not even be activated.
  • VisualEditor does not even try to support template code

It would be fine to have a syntax sensitive editor for mediawiki template code (as we have one for various other languages like css, js, lua, ...) with at least:

  • highlighting of matching braces, apostrophes, parser commands, template pipes vs. table pipes, more fancy stuff ...
  • highlighting of syntax errors, warnings, infos,
  • do automatically prettyprint the code when editing and remove such temporary formatting when saving the code.
  • code folding / unfolding
  • syntax based proposals when typing (e.g. parser commands, parser extensions, ...)
  • integrated in the mediawiki core as the standard editor for template code

Would make it easier to write better template code. And broaden the number of people willing to write template code.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 22 2017, 11:13 PM

CodeEditor exists but is not used on/for Template pages.
CodeMirror is being worked on but that might also not be in scope. Feel free to remove that project tag again.

CodeMirror#templateNesting even solves nested template levels, and all the other hilite stuff.

Restricted Application added a subscriber: jeblad. · View Herald TranscriptAug 25 2017, 10:36 AM

thanks for what has been done until now
still code folding / unfolding (collapsing) like in any IDE is missing

Niharika triaged this task as Lowest priority.Nov 7 2017, 11:54 PM
Restricted Application added a project: Community-Tech. · View Herald TranscriptNov 7 2017, 11:54 PM

Maybe we could enable code folding just in the Template namespace.