Interface

class TagScriptEngine.interface.Adapter[source]

Bases: object

The base class for TagScript blocks.

Implementations must subclass this to create adapters.

get_value(ctx: Context) str | None[source]

Processes the adapter’s actions for a given Context.

Subclasses must implement this.

Parameters:

ctx (Context) – The context object containing the TagScript Verb.

Returns:

The adapters’s processed value.

Return type:

Optional[str]

Raises:

NotImplementedError – The subclass did not implement this required method.

class TagScriptEngine.interface.Block[source]

Bases: object

The base class for TagScript blocks.

Implementations must subclass this to create new blocks.

ACCEPTED_NAMES

The accepted names for this block. This ideally should be set as a class attribute.

Type:

Tuple[str, …]

classmethod will_accept(ctx: Context) bool[source]

Describes whether the block is valid for the given Context.

Parameters:

ctx (Context) – The context object containing the TagScript Verb.

Returns:

Whether the block should be processed for this Context.

Return type:

bool

process(ctx: Context) str | None[source]

Processes the block’s actions for a given Context.

Subclasses must implement this.

Parameters:

ctx (Context) – The context object containing the TagScript Verb.

Returns:

The block’s processed value.

Return type:

Optional[str]

Raises:

NotImplementedError – The subclass did not implement this required method.

TagScriptEngine.interface.verb_required_block(implicit: bool, *, parameter: bool = False, payload: bool = False) Block[source]

Get a Block subclass that requires a verb to implicitly or explicitly have a parameter or payload passed.

Parameters:
  • implicit (bool) – Specifies whether the value is required to be passed implicitly or explicitly. {block()} would be allowed if implicit is False.

  • parameter (bool) – Passing True will cause the block to require a parameter to be passed.

  • payload (bool) – Passing True will cause the block to require the payload to be passed.