Extension:SemanticMustacheFormat

From Linux Web Expert

MediaWiki extensions manual
Semantic Mustache Format
Release status: unmaintained
Implementation ContentHandler , Data extraction
Description Mustache template integration into Semantic MediaWiki queries.
Author(s) Tony Crisci (Wikifoottalk)
Latest version 0.0.1 (2013-08-11)
MediaWiki 1.21+
PHP 5.4+
Database changes No
License GNU General Public License 2.0 or later
Download
README
  • $srfmHelpers
  • $srfmDefaultHelperModule
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').

The SemanticMustacheFormat extension lets your users create views from semantic queries using Mustache templates. It adds the mustache result format to the ask parser function. Mustache templates are defined in the Mustache namespace of the wiki. The query creates the context for a template and the result is rendered to the page. If needed, a Scribunto Lua helper module can be added to the template context to add functions and variables to assist in formatting. After the template is rendered, it is parsed as WikiText along with the rest of the page.

See the README file for a detailed example and detailed usage description.

Installation

Using git

In your extensions directory install the extension and its dependency submodule, mustache.php.

git clone --recursive https://github.com/acrisci/SemanticMustacheFormat.git

Download tarball

  • <translate> <tvar name=1>Download, extract</tvar> and place the file(s) in a directory called <tvar name=name>SemanticMustacheFormat</tvar> in your <tvar name=ext>extensions/</tvar> folder.</translate>
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    require_once "$IP/extensions/SemanticMustacheFormat/SemanticMustacheFormat.php";
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Configuration parameters

In LocalSettings.php

$srfmHelpers: Array of PHP helper functions or variables that will be available in all templates. If the helper is a function, it must be a closure instance or an invokable class.

$srfmDefaultHelperModule: The title of a page in the Module namespace that will be included by default on all templates.

Parameters added to the ask parser function

format=mustache: Use Semantic Mustache Format extension to create the output of this parser function call.

template: Set to the title of a page in the Mustache namespace you would like to use.

helper module: Set to the title of a page in the Module namespace you would like to use for helper functions and variables (requires Scribunto).

formatting=none: Set this to format numbers and quantities to be plain values you can decode easily in helper functions.

has templates=true: Fully parse templates and parser functions after the template has been compiled. Note that the default Mustache tags will conflict with WikiText tags. You can use a different set of delimiters, like ERB style <% and %> by prepending {{=<% %>=}} to your Mustache template.

See also