webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | List of all members
htmltmpl.TemplateCompiler Class Reference

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Member Function Documentation

◆ add_gettext_token()

def htmltmpl.TemplateCompiler.add_gettext_token (   self,
  tokens,
  str 
)
Append a gettext token and gettext string to the tokens array.
    @hidden

◆ compile()

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.

◆ compile_string()

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.        

◆ DEB()

def htmltmpl.TemplateCompiler.DEB (   self,
  str 
)

PRIVATE METHODS #.

Print debugging message to stderr if debugging is enabled.
    @hidden

◆ find_directive()

def htmltmpl.TemplateCompiler.find_directive (   self,
  params 
)
Extract processing directive (TMPL_*) from a statement.
    @hidden

◆ find_name()

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

◆ find_param()

def htmltmpl.TemplateCompiler.find_param (   self,
  param,
  params 
)
Extract value of parameter from a statement.
    @hidden

◆ gettext_tokens()

def htmltmpl.TemplateCompiler.gettext_tokens (   self,
  tokens,
  str 
)
Find gettext strings and return appropriate array of
    processing tokens.
    @hidden

◆ include_templates()

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

◆ parse()

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

◆ read()

def htmltmpl.TemplateCompiler.read (   self,
  filename 
)
Read content of file and return it. Raise an error if a problem
    occurs.
    @hidden

◆ remove_comments()

def htmltmpl.TemplateCompiler.remove_comments (   self,
  template_data 
)
Remove comments from the template data.
    @hidden

◆ strip_brackets()

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

◆ tokenize()

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

The documentation for this class was generated from the following file: