new SourceHandler(configopt)
TemplateData Source Handler
Loads and validates the templatedata and template parameters whether in the page itself or from its parent.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
<optional> |
Properties
|
Extends
- OO.EventEmitter
Methods
buildModel(wikitextopt) → {jQuery.Promise}
Go over the current wikitext and build a new model.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
wikitext |
string |
<optional> |
Source of the template. |
Returns:
Promise resolving into a new Model or is rejected if the model was impossible to create.
- Type
- jQuery.Promise
extractParametersFromTemplateCode(templateCode) → {Array.<string>}
Retrieve template parameters from the template code.
Adapted from https://he.wikipedia.org/wiki/MediaWiki:Gadget-TemplateParamWizard.js
Parameters:
Name | Type | Description |
---|---|---|
templateCode |
string | Source of the template. |
Returns:
An array of parameters that appear in the template code
- Type
- Array.<string>
findModelInString(templateDataString) → {string|null}
Look for a templatedata json string and return it, if it exists.
Parameters:
Name | Type | Description |
---|---|---|
templateDataString |
string | Wikitext templatedata string |
Returns:
The isolated json string. Empty if no templatedata string was found.
- Type
- string | null
getApi(page, getTemplateDataopt) → {jQuery.Promise}
Get information from the MediaWiki API
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
page |
string | Page name |
|
getTemplateData |
boolean |
<optional> |
Fetch the templatedata in the page. |
Returns:
API promise
- Type
- jQuery.Promise
getFullPageName() → {string}
Get page full name
Returns:
Page full name
- Type
- string
getParametersFromTemplateSource(wikitextopt) → {jQuery.Promise}
Retrieve parameters from the template code from source in this order:
- Check if there's a template in the given 'wikitext' parameter. If not,
- Check if there's a template in the current page. If not,
- Check if the page is a subpage and go up a level to check for template code. If none found,
- Repeat until we are in the root of the template
- Save the name of the page where the template is taken from
Cache the templateCodePromise so we don't have to do this all over again on each template code request.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
wikitext |
string |
<optional> |
Optional. Source of the template. |
Returns:
Promise resolving into template parameter array
- Type
- jQuery.Promise
getParentPage() → {string}
Get parent page
Returns:
Parent page
- Type
- string
getTemplateSourceCodeParams() → {Array.<string>}
Set template source code parameters
Returns:
Parameters from the template source code
- Type
- Array.<string>
isPageSubLevel() → {boolean}
Set the page as a sub page of the main template
Returns:
Page is sublevel
- Type
- boolean
setFullPageName(pageNameopt)
Get full page name
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pageName |
string |
<optional> |
"" | Page name |
setPageSubLevel(isSubLevelopt)
Set the page as a sub page of the main template
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
isSubLevel |
boolean |
<optional> |
false | Page is sublevel |
setParentPage(parentopt)
Set parent page
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
parent |
string |
<optional> |
"" | Parent page |
setTemplateSourceCodeParams(params)
Set template source code parameters
Parameters:
Name | Type | Description |
---|---|---|
params |
Array.<string> | Parameters from the template source code |