A class denoting a transclusion template node (a transcluded template, barring any included text or inline parameters) inside an element with [typeof="mw:Transclusion"].

Hierarchy

  • ParsoidTransclusionTemplateNode

Constructors

  • Create a new ParsoidTransclusionTemplateNode.

    Parameters

    • parsoidDocument: ParsoidDocument

      The document handling this transclusion node.

    • originalElement: HTMLElement

      The original element where the data-mw of this node is found.

    • data: any

      The data-mw part.template of this node.

    • i: number

      The i property of this node.

    • autosave: boolean = true

      Whether to automatically save parameter and target changes or not.

    Returns ParsoidTransclusionTemplateNode

Properties

autosave: boolean

Whether to automatically save parameter and target changes or not.

This template's data. This is the value for template for this specific "part" in the data-mw.

element: HTMLElement

The HTMLElement that contains this template.

i: number

The i property of this specific node.

parsoidDocument: ParsoidDocument

The ParsoidDocument handling this node.

Methods

  • Removes this node from its element. This will prevent the node from being saved again.

    Parameters

    • Optional eraseLine: boolean

      For block templates. Setting this to true will also erase a newline that immediately succeeds this template, if one exists. This is useful in ensuring that there are no excesses of newlines in the document.

    Returns void

  • Gets the value of a parameter.

    Parameters

    • key: string

      The key of the parameter to check.

    Returns string

    The parameter value.

  • Gets the parameters of this node.

    Returns {
        [key: string]: {
            wt: string;
        };
    }

    The parameters of this node, in wikitext.

    • [key: string]: {
          wt: string;
      }
      • wt: string
  • Gets the target of this node.

    Returns {
        href?: string;
        wt: string;
    }

    The target of this node, in wikitext and href (for links).

    • Optional href?: string
    • wt: string
  • Checks if a template has a parameter.

    Parameters

    • key: string

      The key of the parameter to check.

    Returns boolean

    true if the template has the given parameter

  • Removes a parameter from the template.

    Parameters

    • key: string

      The parameter key to remove.

    Returns void

  • Sets the value for a specific parameter. If value is null or undefined, the parameter is removed.

    Parameters

    • key: string

      The parameter key to set.

    • value: string

      The new value of the parameter.

    Returns void

  • Sets the target of this template (in wikitext).

    Parameters

    • wikitext: string

      The target template (in wikitext, e.g. Test/{{FULLPAGENAME}}).

    Returns void

  • Creates a new ParsoidTransclusionTemplateNode. Can be used later on to add a template into wikitext. To have this node show up in wikitext, append the node's element (using ParsoidTransclusionTemplateNode.element) to the document of a ParsoidDocument.

    Parameters

    • document: ParsoidDocument

      The document used to generate this node.

    • template: string

      The template to create. If you wish to generate wikitext as a block-type transclusion (as long as a format is not provided through TemplateData), append a "\n" to the end of the template name.

    • Optional parameters: Record<string, string | {
          toString() => string;
      }>

      The parameters to the template.

    • Optional autosave: boolean

    Returns ParsoidTransclusionTemplateNode

    A new ParsoidTransclusionTemplateNode.

Generated using TypeDoc