extras Package

extras Package

This package contains objects used by Nodes, but that are not nodes themselves. This includes template parameters and HTML tag attributes.

attribute Module

class mwparserfromhell.nodes.extras.attribute.Attribute(name, value=None, quotes='"', pad_first=' ', pad_before_eq='', pad_after_eq='')[source]

Bases: StringMixIn

Represents an attribute of an HTML tag.

This is used by Tag objects. For example, the tag <ref name="foo"> contains an Attribute whose name is "name" and whose value is "foo".

static coerce_quotes(quotes)[source]

Coerce a quote type into an acceptable value, or raise an error.

property name

The name of the attribute as a Wikicode object.

property pad_after_eq

Spacing to insert right after the equal sign.

property pad_before_eq

Spacing to insert right before the equal sign.

property pad_first

Spacing to insert right before the attribute.

property quotes

How to enclose the attribute value. ", ', or None.

property value

The value of the attribute as a Wikicode object.

parameter Module

class mwparserfromhell.nodes.extras.parameter.Parameter(name, value, showkey=True)[source]

Bases: StringMixIn

Represents a paramater of a template.

For example, the template {{foo|bar|spam=eggs}} contains two Parameters: one whose name is "1", value is "bar", and showkey is False, and one whose name is "spam", value is "eggs", and showkey is True.

static can_hide_key(key)[source]

Return whether or not the given key can be hidden.

property name

The name of the parameter as a Wikicode object.

property showkey

Whether to show the parameter’s key (i.e., its “name”).

property value

The value of the parameter as a Wikicode object.