Feature summary (what you would like to be able to do and where):
A while ago I made the SkinJSON skin. It renders Skin::getTemplateData (which is a data object passed as input to a Mustache template) as JSON so it can be used as an API or as a reference to skin developers. It is built as a skin rather than an API, as in my attempts to replicate it within the context of an API I was unable to reliably replicate all the hooks/side effects of a skin.
In T306942 we plan to limit skins to rendering the BODY tag of MediaWiki - this constraint should reduce the amount of power skins have traditionally yielded - for example disabling ResourceLoader and adding their own style/script tags which creates an unexpected environment. This would break SkinJSON without a migration path.
I am curious on advice about whether it would make sense to skins that output in formats different to HTML.
Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
- Rendering template data as a JSON in the browser (basically SkinJson use case): this is currently done by SkinJSON using the following hack:
https://github.com/jdlrobson/mediawiki-skins-skinjson/blob/master/SkinJSON.php#L312
It would be nice if instead, SkinJSON could declare its content type to avoid having to do this. It would likely need to be done in the communication between OutputPage and Skin.php
Other hypothetical use cases that might be useful:
- Rendering ATOM feeds
- Rendering content types other than wikitext in their native format.
- In future perhaps this could be used for API e.g. skinversion=3 to support different versioned formats e.g. the skin layer could pull out existing logic for skinversion=2 from the API e.g. mapping Objects to arrays and it would be easier for 3rd parties that want custom APIs to use the skinning layer to render JSON in different desired output.
Benefits (why should this be implemented?):
- Rendering things in a format other than HTML fits the mould of what I would expect a Skin to be able to do.
- It's clearer what the boundaries of a skin are