Creates a new instance.
Usage:
const template = new mwbot.Template('Template title');
The title that the template transcludes.
Optional
params: NewTemplateParameter[]Template parameters.
Optional
hierarchies: TemplateParameterHierarchiesOptional template parameter hierarchies.
Checks if the given object is an instance of the specified template-related class.
This method is an alternative of the instanceof
operator, which cannot be used for
non-exported classes.
Example:
const [foo] = new mwbot.Wikitext('{{Foo}}').parseTemplates();
foo instanceof mwbot.Template; // true
mwbot.Template.is(foo, 'ParsedTemplate'); // true
mwbot.Template.is(foo, 'RawTemplate'); // false
foo instanceof mwbot.ParserFunction; // false
mwbot.Template.is(foo, 'ParsedParserFunction'); // false
Be noted about the hierarchies of the template-related classes:
The type of template to check for. Must be one of 'Template'
, 'ParsedTemplate'
,
'RawTemplate'
, 'ParserFunction'
, or 'ParsedParserFunction'
.
The object to check.
The template type to compare against.
true
if obj
is an instance of the specified template class, otherwise false
.
Error-proof constructor.
Usage:
const template = mwbot.Template.new('Template title');
The title that the template transcludes.
Optional
params: NewTemplateParameter[]Template parameters.
Optional
hierarchies: TemplateParameterHierarchiesOptional template parameter hierarchies.
null
if initialization fails.
This interface defines the static members of the
Template
class. For instance members, see Template (defined separately due to TypeScript limitations).Template
is a class that serves to parse{{template}}
markups into an object structure, which is accessible via Mwbot.Template. Note that{{#parserfunction:}}
markups are treated differently by the ParserFunction class.Example