webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Public Member Functions | |
def | __init__ (self, include=1, max_include=5, comments=1, gettext=0, debug=0) |
def | compile (self, file) |
def | compile_string (self, data) |
def | DEB (self, str) |
PRIVATE METHODS #. More... | |
def | read (self, filename) |
def | parse (self, template_data) |
def | remove_comments (self, template_data) |
def | include_templates (self, tokens) |
def | tokenize (self, template_data) |
def | gettext_tokens (self, tokens, str) |
def | add_gettext_token (self, tokens, str) |
def | strip_brackets (self, statement) |
def | find_directive (self, params) |
def | find_name (self, params) |
def | find_param (self, param, params) |
Preprocess, parse, tokenize and compile the template. This class parses the template and produces a 'compiled' form of it. This compiled form is an instance of the <em>Template</em> class. The compiled form is used as input for the TemplateProcessor which uses it to actually process the template. This class should be used direcly only when you need to compile a template from a string. If your template is in a file, then you should use the <em>TemplateManager</em> class which provides a higher level interface to this class and also can save the compiled template to disk in a precompiled form.
def htmltmpl.TemplateCompiler.__init__ | ( | self, | |
include = 1 , |
|||
max_include = 5 , |
|||
comments = 1 , |
|||
gettext = 0 , |
|||
debug = 0 |
|||
) |
Constructor. @header __init__(include=1, max_include=5, comments=1, gettext=0, debug=0) @param include Enable or disable included templates. @param max_include Maximum depth of nested inclusions. @param comments Enable or disable template comments. @param gettext Enable or disable gettext support. @param debug Enable or disable debugging messages.
def htmltmpl.TemplateCompiler.add_gettext_token | ( | self, | |
tokens, | |||
str | |||
) |
Append a gettext token and gettext string to the tokens array. @hidden
def htmltmpl.TemplateCompiler.compile | ( | self, | |
file | |||
) |
Compile template from a file. @header compile(file) @return Compiled template. The return value is an instance of the <em>Template</em> class. @param file Filename of the template. See the <em>prepare()</em> method of the <em>TemplateManager</em> class for exaplanation of this parameter.
def htmltmpl.TemplateCompiler.compile_string | ( | self, | |
data | |||
) |
Compile template from a string. This method compiles a template from a string. The template cannot include any templates. <strong>TMPL_INCLUDE</strong> statements are turned into warnings. @header compile_string(data) @return Compiled template. The return value is an instance of the <em>Template</em> class. @param data String containing the template data.
def htmltmpl.TemplateCompiler.DEB | ( | self, | |
str | |||
) |
PRIVATE METHODS #.
Print debugging message to stderr if debugging is enabled. @hidden
def htmltmpl.TemplateCompiler.find_directive | ( | self, | |
params | |||
) |
Extract processing directive (TMPL_*) from a statement. @hidden
def htmltmpl.TemplateCompiler.find_name | ( | self, | |
params | |||
) |
Extract identifier from a statement. The identifier can be specified both implicitely or explicitely as a 'NAME' parameter. @hidden
def htmltmpl.TemplateCompiler.find_param | ( | self, | |
param, | |||
params | |||
) |
Extract value of parameter from a statement. @hidden
def htmltmpl.TemplateCompiler.gettext_tokens | ( | self, | |
tokens, | |||
str | |||
) |
Find gettext strings and return appropriate array of processing tokens. @hidden
def htmltmpl.TemplateCompiler.include_templates | ( | self, | |
tokens | |||
) |
Process TMPL_INCLUDE statements. Use the include_level counter to prevent infinite recursion. Record paths to all included templates to self._include_files. @hidden
def htmltmpl.TemplateCompiler.parse | ( | self, | |
template_data | |||
) |
Parse the template. This method is recursively called from within the include_templates() method. @return List of processing tokens. @hidden
def htmltmpl.TemplateCompiler.read | ( | self, | |
filename | |||
) |
Read content of file and return it. Raise an error if a problem occurs. @hidden
def htmltmpl.TemplateCompiler.remove_comments | ( | self, | |
template_data | |||
) |
Remove comments from the template data. @hidden
def htmltmpl.TemplateCompiler.strip_brackets | ( | self, | |
statement | |||
) |
Strip HTML brackets (with optional HTML comments) from the beggining and from the end of a statement. @hidden
def htmltmpl.TemplateCompiler.tokenize | ( | self, | |
template_data | |||
) |
Split the template into tokens separated by template statements. The statements itself and associated parameters are also separately included in the resulting list of tokens. Return list of the tokens. @hidden