Extensions should be able to extend mw.title by adding attributes to them.
Use cases:
- T71441: Feature request: add detection for disambiguation pages to Scribunto
- T380122: Expose WikiProject assessment information to Lua
- T216356: Allow access to the page's local description via the title object
- T131911: Allow retrieving page image name from wikitext using Scribunto or parser function
Proposed hook design:
- onScribuntoLuaTitleAttributes( LuaEngine $engine, array &$resolvers )
- $resolvers is an associative array mapping attribute names to resolver functions that take the LinkTarget and the LuaEngine, and return an arbitrary value to be set as the attribute value.
- Sample implementation: coming soon
- $resolvers is an associative array mapping attribute names to resolver functions that take the LinkTarget and the LuaEngine, and return an arbitrary value to be set as the attribute value.
- In case the returned php value needs to have some postprocessing done at the Lua side, the resolver returns an array in which a __transformer key is set to the name of a transformer function. The entire array is passed to the transformer function defined on Lua side. Scribunto core will provide some transformers like titleFromText (for the attribute to resolve to an mw.title object) and languageFromName (to resolve to an mw.language object). It will not be possible for extensions to define their own transformers.