Tayra

Template. Script. Distribute

compiler – Compiler

Tayra Compiler implemented as plugin. It also implements pluggapps’ web interface ITemplate.

Module contents

class tayra.compiler.TTLCompiler(pa, *args, **kwargs)[source]

Bases: pluggdapps.plugin.Plugin

Tayra compiler. Implemented as plugin to leverage on pluggdapps configuration system. Also implement ITemplate. Creating a plugin instance can be a costly operation, to avoid this instantiate this plugin once and use _init() to initialize it for subsequent uses.

__call__(**kwargs)[source]

Clone a plugin with the same settings as this one. settings can also be overriden by passing settings key-word argument as a dictionary.

compilettl(file=None, text=None, args=[], kwargs={})[source]

Translate a template script text or template script file into intermediate python text. Compile the python text and return the code object. If memcache configuration is enable, compile code is cached in memory using a hash value generated from template text.

args and kwargs,
position arguments and keyword arguments to use during AST.generate() pass.
encoding = ''

Character encoding of original template script file.

generatehtml(module, context={})[source]

Using the module object obtained from load() method, and a context dictionary, call the template module’s entry point to generate HTMl text and return the same.

igen = None

tayra.codegen.InstrGen object.

load(code, context={})[source]

Using an optional context, a dictionary of key-value pairs, and the code object obtained from compilettl() method, create a new module instance populating it with context and some standard references.

mach = None

tayra.runtime.StackMachine object.

pyfile = ''

If present, absolute file path pointing to compiled template script, .py file.

pytext = ''

String of python script translated from template script.

render(context, **kwargs)[source]

pluggdapps.interfaces.ITemplate.render() interface method. Generate HTML string from template script passed either via ttext or via tfile.

tfile,
Location of Tayra template file, either as relative directory or as asset specification.
ttext,
Tayra template text string.
toast(ttltext=None)[source]

Convert template text into abstract-syntax-tree. Return the root node tayra.ast.Template.

topy(ast, *args, **kwargs)[source]

Generate intermediate python text from ast obtained from toast() method. If configuration settings allow for persisting the generated python text, then this method will save the intermediate python text in file pointed by pyfile.

ttlfile = ''

Absolute file path pointing to .ttl template script file in.

ttlloc = None

TemplateLookup object. Encapsulates location information for template file and its intermediate python file.

ttlparser = None

tayra.parser.TTLParser object.

ttltext = ''

String of template script either read from the template file or received directly.

class tayra.compiler.TemplateLookup(compiler, ttlloc=None, ttltext=None)[source]

Bases: builtins.object

Lookup template file, template text, intermediate python file.

encoding = ''

Character encoding of original template script file.

pyfile = ''

Absolute file path pointing to compiled template script, .py file.

ttlfile = ''

Absolute file path pointing to .ttl template script file in.

ttlhash

Hash value generated from template text.

ttltext = ''

String of template script either read from the template file or received directly.

Table Of Contents

Related Topics

This Page