Tayra uses pluggdapps component system, and heavily based on plugins. The lexer and parser are just a glue logic over a very sophisticated plugin framework which does most of the language level heavy lifting. This modules contains all the interface specifications that matters to tayra language implementation.
Bases: pluggdapps.plugin.Interface
Interface specification to translate template tags to HTML tags. Plugins implementing this interface is defined under tayra.tags package. It is possible for developers to implement their own plugins to translate template tags just by configuring tayra.compiler.TTLCompiler plugin.
Called during runtime, translates tayra tag into HTML tags. Returns html string.
Bases: pluggdapps.plugin.Interface
Interface specification to handle expressions within template script. IMPORTANT : Plugins implementing this interface should have its name prefixed with ‘TayraExpression’. For instance a plugin implementing python expression evaluation will look like, ExpressionPy, and in the template script this plugin can be referred as,:
${-py <python-expression>}
Evaluate text expression in the context of globals_ and locals_. Return evaluated expression converted to a string. This string will be substituted in the place where the expression is refered.
Inside the template script, filtering is applied on the expression result using the following syntax,:
${ ... | <filters> }
Stack machine mach will parse <filter> spec and call this method along with evaluated text.
If filter name is successfully applied return filterted text, else return None.
Bases: pluggdapps.plugin.Interface
Interface specification for filter blocks to handle blocks of template code that does not follow indentation rules, can potentially have a separate syntax to themself and they can take part in multi-pass compilation.
Will be called during the generate phase, traversing AST. Can optionally return a value which will then be passed to tailpass.
Will be called during the headpass phase 1, traversing AST. Can optionally return a value which will then be passed to headpass2.
Will be called during the headpass phase 2, traversing AST. Can optionally return a value which will then be passed to generate.
Will be called during the tailpass phase, traversing AST. Can optionally return a value which will then be passed to tailpass.