Modules
wheezy.template
- class wheezy.template.CodeExtension(token_start: str = '@')[source]
Includes support for embedded python code.
- class wheezy.template.CoreExtension(token_start: str = '@', line_join: str = '\\')[source]
Includes basic statements, variables processing and markup.
- class wheezy.template.DictLoader(templates: Mapping[str, str])[source]
Loads templates from python dictionary.
templates- a dict where key corresponds to template name and value to template content.
- class wheezy.template.Engine(loader: Loader, extensions: List[Any], template_class: Callable[[str, Callable[[Mapping[str, Any], Mapping[str, Any], Mapping[str, Any]], str]], SupportsRender] | None = None)[source]
The core component of template engine.
- class wheezy.template.FileLoader(directories: List[str], encoding: str = 'UTF-8')[source]
Loads templates from file system.
directories- search path of directories to scan for template.encoding- decode template content per encoding.
wheezy.template.builder
wheezy.template.compiler
wheezy.template.console
wheezy.template.engine
- class wheezy.template.engine.Engine(loader: Loader, extensions: List[Any], template_class: Callable[[str, Callable[[Mapping[str, Any], Mapping[str, Any], Mapping[str, Any]], str]], SupportsRender] | None = None)[source]
The core component of template engine.
- class wheezy.template.engine.Template(name: str, render_template: Callable[[Mapping[str, Any], Mapping[str, Any], Mapping[str, Any]], str])[source]
Simple template class.
- wheezy.template.engine.complement_syntax_error(err: SyntaxError, template_source: str, source: str) SyntaxError[source]
Complements SyntaxError with template and source snippets, like one below:
File "shared/snippet/widget.html", line 4 if : template snippet: 02 <h1> 03 @msg!h 04 @if : 05 sd 06 @end generated snippet: 02 _b = []; w = _b.append; w('<h1>\n ') 03 w(h(msg)); w('\n') 04 if : 05 w(' sd\n') 06 if : ^ SyntaxError: invalid syntax
wheezy.template.lexer
- class wheezy.template.lexer.Lexer(lexer_rules: List[tuple[Pattern[str], Callable[[Match[str]], tuple[int, str, str]]]], preprocessors: List[Callable[[str], str]] | None = None, postprocessors: List[Callable[[list[tuple[int, str, str]]], str]] | None = None, **ignore: Any)[source]
Tokenizes input source per rules supplied.
wheezy.template.loader
- class wheezy.template.loader.ChainLoader(loaders: List[Loader])[source]
Loads templates from
loadersuntil first succeed.
- class wheezy.template.loader.DictLoader(templates: Mapping[str, str])[source]
Loads templates from python dictionary.
templates- a dict where key corresponds to template name and value to template content.
- class wheezy.template.loader.FileLoader(directories: List[str], encoding: str = 'UTF-8')[source]
Loads templates from file system.
directories- search path of directories to scan for template.encoding- decode template content per encoding.
wheezy.template.parser
- class wheezy.template.parser.Parser(parser_rules: Dict[str, Callable[[str], str | list[str]]], parser_configs: List[Callable[[ParserConfig], None]] | None = None, **ignore: Any)[source]
continue_tokensare used to insertendnode right before them to simulate a block end. Such nodes have token valueNone.out_tokensare combined together into a single node.
wheezy.template.preprocessor
wheezy.template.utils
wheezy.template.ext.code
wheezy.template.ext.core
- class wheezy.template.ext.core.CoreExtension(token_start: str = '@', line_join: str = '\\')[source]
Includes basic statements, variables processing and markup.
- wheezy.template.ext.core.rvalue_token(m: Match[str]) tuple[int, str, str][source]
Produces variable token as r-value expression.
wheezy.template.ext.determined
- class wheezy.template.ext.determined.DeterminedExtension(known_calls: List[str], runtime_token_start: str = '@', token_start: str = '#')[source]
Tranlates function calls between template engines.
Strictly determined known calls are converted to preprocessor calls, e.g.:
@_('Name:') @path_for('default') @path_for('static', path='/static/css/site.css')
Those that are not strictly determined are ignored and processed by runtime engine.
- wheezy.template.ext.determined.determined(expression: str) bool[source]
Checks if expresion is strictly determined.
>>> determined("'default'") True >>> determined('name') False >>> determined("'default', id=id") False >>> determined("'default', lang=100") True >>> determined('') True
- wheezy.template.ext.determined.parse_args(text: str) List[str][source]
Parses argument type of parameters.
>>> parse_args('') [] >>> parse_args('10, "x"') ['10', '"x"'] >>> parse_args("'x', 100") ["'x'", '100'] >>> parse_args('"default"') ['"default"']
- wheezy.template.ext.determined.parse_kwargs(text: str) Mapping[str, str][source]
Parses key-value type of parameters.
>>> parse_kwargs('id=item.id') {'id': 'item.id'} >>> sorted(parse_kwargs('lang="en", id=12').items()) [('id', '12'), ('lang', '"en"')]
- wheezy.template.ext.determined.parse_params(text: str) tuple[List[str], Mapping[str, str]][source]
Parses function parameters.
>>> parse_params('') ([], {}) >>> parse_params('id=item.id') ([], {'id': 'item.id'}) >>> parse_params('"default"') (['"default"'], {}) >>> parse_params('"default", lang="en"') (['"default"'], {'lang': '"en"'})