Page MenuHomePhabricator

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

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:

  • T261857 highlighting of matching braces, apostrophes, parser commands, template pipes vs. table pipes, more fancy stuff ...
  • T381577 highlighting of syntax errors, warnings, infos,
  • automatically prettyprint the code when editing and remove such temporary formatting when saving the code.
  • T30684 code folding / unfolding
  • T95100 syntax based proposals when typing (e.g. parser commands, parser extensions, ...)
  • T391926 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.

Related Objects

StatusSubtypeAssignedTask
OpenFeatureNone
ResolvedFeatureBhsd
OpenGoalNone
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedBhsd
ResolvedBUG REPORTBhsd
ResolvedMusikAnimal
StalledMusikAnimal
ResolvedTheresNoTime
ResolvedMusikAnimal
OpenNone
OpenBUG REPORTNone
OpenMusikAnimal
ResolvedBUG REPORTMusikAnimal
ResolvedBUG REPORTFunc
ResolvedBUG REPORTMusikAnimal
OpenNone
ResolvedBUG REPORTFunc
ResolvedBUG REPORTFunc
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
OpenNone
OpenFeatureNone
Resolvedawight
ResolvedLena_WMDE
ResolvedLena_WMDE
OpenFeatureNone
ResolvedMusikAnimal
ResolvedBhsd
OpenMusikAnimal
ResolvedMusikAnimal
ResolvedBUG REPORTBhsd
ResolvedFeatureBhsd
ResolvedFeatureBhsd

Event Timeline

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.

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

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

Izno changed the subtype of this task from "Task" to "Feature Request".Oct 5 2023, 1:47 AM

The checkbox "do automatically prettyprint the code when editing and remove such temporary formatting when saving the code" is checked off on the list in the task description. It was checked off by @Bhsd in January 2024 at T166098#9469820. Unless I'm misunderstanding what this point is talking about, it has not been done. There's no additional context available since it doesn't link to a subtask like the others do. Was this a mistake? If not, can someone clarify the text or add a link to a relevant Phabricator task? Thanks.