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.
- class mwparserfromhell.nodes.extras.Attribute(name: Any, value: Any = None, quotes: str | None = '"', pad_first: str = ' ', pad_before_eq: str = '', pad_after_eq: str = '')[source]¶
Bases:
StringMixInRepresents an attribute of an HTML tag.
This is used by
Tagobjects. For example, the tag<ref name="foo">contains an Attribute whose name is"name"and whose value is"foo".- static coerce_quotes(quotes: Any) str | None[source]¶
Coerce a quote type into an acceptable value, or raise an error.
- property pad_after_eq: str¶
Spacing to insert right after the equal sign.
- property pad_before_eq: str¶
Spacing to insert right before the equal sign.
- property pad_first: str¶
Spacing to insert right before the attribute.
- property quotes: str | None¶
How to enclose the attribute value.
",', orNone.
- class mwparserfromhell.nodes.extras.Parameter(name: Any, value: Any, showkey: bool = True)[source]¶
Bases:
StringMixInRepresents a parameter of a template.
For example, the template
{{foo|bar|spam=eggs}}contains two Parameters: one whose name is"1", value is"bar", andshowkeyisFalse, and one whose name is"spam", value is"eggs", andshowkeyisTrue.- static can_hide_key(key: Any) Match | None[source]¶
Return whether or not the given key can be hidden.
- property showkey: bool¶
Whether to show the parameter’s key (i.e., its “name”).