Tayra

Template. Script. Distribute

tags – Tag handlers

Template tags have one-to-one correspondence with HTML tags. On top of that plugins can extend tag definitions, adding composite tags, by implementing tayra.interfaces.ITayraTags interface specification. An example of this can be found in tayra.tags.forms.HTML5Forms plugin. Plugins wanting to implement ITayraTags interface must derive from the base class Tags defined in this module. The base class defines standard specifier tokens common to all template tags, also gracefully handles undefined tags in safest possible way.

Tag meta syntax,:

<tagname list-of-specifiers { inline-css-style } list-of-attributes>
tagname,
can be standard HTML tag or custom tags that are translated to HTML tags by a plugin.
specifiers,
a token or string that are delimited by whitespace.
style,
CSS style parameters that can be otherwise specified as value for style attribute.
attribute,
regular HTML attributes.

List of specifiers that are common to all template tags.

  • id attribute can be specified as #<id-value>.
  • class attribute can be specified as .<class1>.<class2>
  • name attribute can be specified as :<name>.

tokens that will be translated to attribute values.

token Equivalent attribute pairs
edit contenteditable=”true”
noedit contenteditable=”false”
dragcopy draggable=”true” dragzone=”copy”
dragmove draggable=”true” dragzone=”move”
draglink draggable=”true” dragzone=”link”
nodrag draggable=”false”
hidden hidden
spellcheck spellcheck=”true”
nospellcheck spellcheck=”false”
ltr dir=”ltr”
rtl dir=”rtl”
disabled disabled=”disabled”
checked checked=”checked”
readonly readonly=”readonly”
selected selected=”selected”
multiple multiple=”multiple”
defer defer=”defer”

Module Contents

class tayra.tags.Tags(pa, *args, **kwargs)[source]

Bases: pluggdapps.plugin.Plugin

Base class for all plugins wanting to handle template tags. Since the base class declares that it implements tayra.interfaces.ITayraTags interface, deriving plugins need not do the same.

  • provides standard specifier syntax for common tag attributes.
  • gracefully handles undefined tags.
classmethod default_settings()[source]

pluggdapps.plugin.ISettings.default_settings() interface method.

handle(mach, tagname, tokens, styles, attributes, content)[source]

pluggdapps.plugin.ISettings.default_settings() interface method.

This method is expected to be overriden by the deriving plugin class, only for undefined template tags this method will be called, after trying with other plugins in the list of tag.plugins.

classmethod normalize_settings(sett)[source]

pluggdapps.plugin.ISettings.normalize_settings() interface method.

parse_specs(tokens, styles, attributes)[source]

The base class provides standard set of tokens and specifiers that are common to most HTML tags. To parse these tokens into tag-attributes, deriving plugins can use this method.