ll.ul4c
provides templating for XML/HTML as well as any other text-based
format. A template defines placeholders for data output and basic logic (like
loops and conditional blocks), that define how the final rendered output will
look.
ll.ul4c
compiles a template to an internal format, which makes it
possible to implement template renderers in multiple programming languages.
def register
(name
):
def withcontext
(f
):
Normally when a function is exposed to UL4 this function will be called directly.
However when the function needs access to the rendering context (i.e. the local variables or information about the call stack), the function must have an additional first parameter, and UL4 must be told that this parmeter is required.
This call be done with this decorator.
class Error
(Exception
):
Exception class that wraps another exception and provides a location.
def __init__
(self
, node
, template
=None
):
def __repr__
(self
):
def __str__
(self
):
class BlockError
(Exception
):
Exception that is raised by the compiler when an illegal block structure is
detected (e.g. an <?end if?>
without a previous <?if?>
).
def __init__
(self
, message
):
def __str__
(self
):
class BreakException
(Exception
):
class ContinueException
(Exception
):
class ReturnException
(Exception
):
def __init__
(self
, value
):
class Undefined
(object
):
def __bool__
(self
):
def __iter__
(self
):
def __len__
(self
):
def __call__
(self
, *args
, **kwargs
):
def __getattr__
(self
, key
):
def __getitem__
(self
, key
):
class UndefinedKey
(Undefined
):
def __init__
(self
, key
):
def __repr__
(self
):
class UndefinedVariable
(Undefined
):
def __init__
(self
, name
):
def __repr__
(self
):
class UndefinedIndex
(Undefined
):
def __init__
(self
, index
):
def __repr__
(self
):
class Context
(object
):
A Context
object stores the context of a call to a template. This
consists of the local variables and the indent stack.
def __init__
(self
):
def replacevars
(*args
, **kwds
):
def chainvars
(*args
, **kwds
):
def _handleexpressioneval
(f
):
Decorator for an implementation of the eval
method that does not
do output (so it is a normal method).
This decorator is responsible for exception handling. An exception that bubbles up the Python call stack will generate an exception chain that follows the UL4 call stack.
def _handleoutputeval
(f
):
Decorator for an implementation of the eval
method that does output
(so it is a generator).
This decorator is responsible for exception handling. An exception that bubbles up the Python call stack will generate an exception chain that follows the UL4 call stack.
def _unpackvar
(lvalue
, value
):
A generator used for recursively unpacking values for assignment.
lvalue
may be an AST
object (in which case the recursion ends)
or a (possible nested) sequence of AST
objects.
The values produced are (AST node, value) tuples.
def _makevars
(signature
, args
, kwargs
):
Bind args
and kwargs
to the inspect.Signature
object
signature
and return the resulting argument dictionary. (This differs
from inspect.Signature.bind
in that it handles default values too.)
signature
may also be None
in which case args
must be empty
and :obj:kwargs is returned, i.e. the signature is treated als accepting no
positional argument and any keyword argument.
def _ul4getattr
(obj
, name
):
Return the attribute name
of the object :obj`obj` and honor
ul4getattr
and ul4attrs
.
def _ul4setattr
(obj
, name
, value
):
Set the attribute name
of the object :obj`obj` to value
and
honor ul4setattr
and ul4attrs
.
def _str
(obj
=''
):
def _repr_helper
(obj
, seen
):
def _repr
(obj
):
def _asjson
(obj
):
def _xmlescape
(obj
):
class AST
(object
):
Base class for all syntax tree nodes.
def __init__
(self
, startpos
=None
, endpos
=None
):
def _linecol
(source
, startpos
, endpos
):
def __repr__
(self
):
def _repr
(self
):
def _repr_pretty_
(self
, p
, cycle
):
def _repr_pretty
(self
, p
):
def __str__
(self
):
def eval
(self
, context
):
This evaluates the node.
For most nodes this is a normal function that returns the result of
evaluating the node. (For these nodes the class attribute output
is false.). For nodes that produce output (like literal text,
Print
, PrintX
or Render
) it is a generator
which yields the text output of the node. For blocks (which might contain
nodes which produce output) this is also a generator. (For these nodes
the class attribute output
is true.)
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Text
(AST
):
AST node for literal text.
def __init__
(self
, source
=None
, startpos
=None
, endpos
=None
):
def _linecol
(self
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
property text:
def __get__
(self
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def eval
(self
, context
):
class Indent
(Text
):
AST node for literal text that is an indentation at the start of the line.
def __init__
(self
, source
=None
, startpos
=None
, endpos
=None
, text
=None
):
property text:
def __get__
(self
):
def _settext
(self
, text
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def eval
(self
, context
):
class LineEnd
(Text
):
AST node for literal text that is the end of a line.
def _str
(self
):
class Tag
(AST
):
A Tag
object is the location of a template tag in a template.
def __init__
(self
, source
=None
, tag
=None
, startpos
=None
, endpos
=None
, startposcode
=None
, endposcode
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def _linecol
(self
):
def __str__
(self
):
property text:
def __get__
(self
):
property code:
def __get__
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Code
(AST
):
The base class of all AST nodes that appear inside a Tag
.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
):
def _linecol
(self
):
property text:
def __get__
(self
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Const
(Code
):
Load a constant
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, value
=None
):
def eval
(self
, context
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
class List
(Code
):
AST nodes for loading a list object.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, *items
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class ListComp
(Code
):
AST node for list comprehension.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, item
=None
, varname
=None
, container
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Set
(Code
):
AST nodes for loading a set object.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, *items
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class SetComp
(Code
):
AST node for set comprehension.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, item
=None
, varname
=None
, container
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Dict
(Code
):
AST node for loading a dict object.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, *items
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class DictComp
(Code
):
AST node for dictionary comprehension.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, key
=None
, value
=None
, varname
=None
, container
=None
, condition
=None
):
def __repr__
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class GenExpr
(Code
):
AST node for a generator expression.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, item
=None
, varname
=None
, container
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, context
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Var
(Code
):
AST nodes for loading a variable.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, name
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def evalset
(self
, *args
, **kwargs
):
def evalmodify
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Block
(Code
):
Base class for all AST nodes that are blocks.
A block contains a sequence of AST nodes that are executed sequencially.
A block may execute its content zero (e.g. an <?if?>
block) or more times
(e.g. a <?for?>
block).
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
):
def append
(self
, item
):
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class CondBlock
(Block
):
AST node for an conditional block.
The content of the CondBlock
block is one IfBlock
block
followed by zero or more ElIfBlock
blocks followed by zero or one
ElseBlock
block.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, condition
=None
):
def _repr_pretty
(self
, p
):
def append
(self
, item
):
def newblock
(self
, block
):
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class IfBlock
(Block
):
AST node for an <?if?>
block.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class ElIfBlock
(Block
):
AST node for an <?elif?>
block.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class ElseBlock
(Block
):
AST node for an <?else?>
block.
def _repr_pretty
(self
, p
):
def _str
(self
):
class ForBlock
(Block
):
AST node for a <?for?>
loop.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, varname
=None
, container
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class WhileBlock
(Block
):
AST node for a <?while?>
loop.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, condition
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class Break
(Code
):
AST node for a <?break?>
inside a <?for?>
block.
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class Continue
(Code
):
AST node for a <?continue?>
inside a <?for?>
block.
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class Attr
(Code
):
AST node for getting and setting an attribute of an object.
The object is loaded from the AST node obj
and the attribute name
is stored in the string attrname
.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, obj
=None
, attrname
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def method_str
(self
, obj
, methname
):
def method_list
(self
, obj
, methname
):
def method_set
(self
, obj
, methname
):
def method_ul4attrs
(self
, obj
, methname
):
def method_dict
(self
, obj
, methname
):
def method_date
(self
, obj
, methname
):
def method_timedelta
(self
, obj
, methname
):
def evalset
(self
, *args
, **kwargs
):
def evalmodify
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Slice
(Code
):
AST node for creating a slice object (used in obj[index1:index2]
).
The start and stop indices are loaded from the AST nodes index1
and
index2
. index1
and index2
may also be None
(for missing slice indices, which default to the 0 for the start index and
the length of the sequence for the end index).
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, index1
=None
, index2
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Unary
(Code
):
Base class for all AST nodes implementing unary operators.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, obj
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def eval
(self
, *args
, **kwargs
):
class Not
(Unary
):
AST node for the unary not
operator.
class Neg
(Unary
):
AST node for the unary negation (i.e. "-") operator.
class BitNot
(Unary
):
AST node for the bitwise not operator.
class Print
(Unary
):
AST node for a <?print?>
tag.
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class PrintX
(Unary
):
AST node for a <?printx?>
tag.
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class Return
(Unary
):
AST node for a <?return?>
tag.
def _str
(self
):
def eval
(self
, *args
, **kwargs
):
class Binary
(Code
):
Base class for all AST nodes implementing binary operators.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, obj1
=None
, obj2
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def eval
(self
, *args
, **kwargs
):
class Item
(Binary
):
AST node for subscripting operator.
The object (which must be a list, string or dict) is loaded from the AST
node obj1
and the index/key is loaded from the AST node obj2
.
def evalset
(self
, *args
, **kwargs
):
def evalmodify
(self
, *args
, **kwargs
):
class Is
(Binary
):
AST node for the binary is
comparison operator.
class IsNot
(Binary
):
AST node for the binary is not
comparison operator.
class EQ
(Binary
):
AST node for the binary ==
comparison operator.
class NE
(Binary
):
AST node for the binary !=
comparison operator.
class LT
(Binary
):
AST node for the binary <
comparison operator.
class LE
(Binary
):
AST node for the binary <=
comparison operator.
class GT
(Binary
):
AST node for the binary >
comparison operator.
class GE
(Binary
):
AST node for the binary >=
comparison operator.
class Contains
(Binary
):
AST node for the binary containment testing operator.
The item/key object is loaded from the AST node obj1
and the container
object (which must be a list, string, dict or an object with a ul4attrs
attribute) is loaded from the AST node obj2
.
class NotContains
(Binary
):
AST node for the inverted containment testing operator.
The item/key object is loaded from the AST node obj1
and the container
object (which must be a list, string, dict or an object with a ul4attrs
attribute) is loaded from the AST node obj2
.
class Add
(Binary
):
AST node for the binary addition operator.
class Sub
(Binary
):
AST node for the binary substraction operator.
class Mul
(Binary
):
AST node for the binary multiplication operator.
class FloorDiv
(Binary
):
AST node for the binary truncating division operator.
class TrueDiv
(Binary
):
AST node for the binary true division operator.
class Mod
(Binary
):
AST node for the binary modulo operator.
class ShiftLeft
(Binary
):
AST node for the bitwise left shift operator.
class ShiftRight
(Binary
):
AST node for the bitwise right shift operator.
class BitAnd
(Binary
):
AST node for the binary bitwise and operator (&
).
class BitXOr
(Binary
):
AST node for the binary bitwise exclusive or operator (^
).
class BitOr
(Binary
):
AST node for the binary bitwise or operator (|
).
class And
(Binary
):
AST node for the binary and
operator.
def eval
(self
, *args
, **kwargs
):
class Or
(Binary
):
AST node for the binary or
operator.
def eval
(self
, *args
, **kwargs
):
class If
(Code
):
AST node for the ternary inline if/else
operator.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, objif
=None
, objcond
=None
, objelse
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def eval
(self
, *args
, **kwargs
):
class ChangeVar
(Code
):
Baseclass for all AST nodes that store or modify a variable.
The left hand side is loaded from the AST node label
and the value that
will be stored or be used to modify the stored value is loaded from the
AST node value
.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, lvalue
=None
, value
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class SetVar
(ChangeVar
):
AST node that stores a value into a variable.
def eval
(self
, *args
, **kwargs
):
class AddVar
(ChangeVar
):
AST node that adds a value to a variable (i.e. the +=
operator).
def eval
(self
, *args
, **kwargs
):
class SubVar
(ChangeVar
):
AST node that substracts a value from a variable (i.e. the -=
operator).
def eval
(self
, *args
, **kwargs
):
class MulVar
(ChangeVar
):
AST node that multiplies a variable by a value (i.e. the *=
operator).
def eval
(self
, *args
, **kwargs
):
class FloorDivVar
(ChangeVar
):
AST node that divides a variable by a value (truncating to an integer value;
i.e. the //=
operator).
def eval
(self
, *args
, **kwargs
):
class TrueDivVar
(ChangeVar
):
AST node that divides a variable by a value (i.e. the /=
operator).
def eval
(self
, *args
, **kwargs
):
class ModVar
(ChangeVar
):
AST node for the %=
operator.
def eval
(self
, *args
, **kwargs
):
class ShiftLeftVar
(ChangeVar
):
AST node for the <<=
operator.
def eval
(self
, *args
, **kwargs
):
class ShiftRightVar
(ChangeVar
):
AST node for the >>=
operator.
def eval
(self
, *args
, **kwargs
):
class BitAndVar
(ChangeVar
):
AST node for the &=
operator.
def eval
(self
, *args
, **kwargs
):
class BitXOrVar
(ChangeVar
):
AST node for the ^=
operator.
def eval
(self
, *args
, **kwargs
):
class BitOrVar
(ChangeVar
):
AST node for the |=
operator.
def eval
(self
, *args
, **kwargs
):
class Call
(Code
):
AST node for calling an object.
The object to be called is stored in the attribute obj
. The list of
arguments is found in args
.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, obj
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, context
):
def evalset
(self
, *args
, **kwargs
):
def evalmodify
(self
, *args
, **kwargs
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Render
(Call
):
AST node for rendering a template.
The template to be rendered is stored in the attribute obj
. The list
of arguments is found in args
.
def __init__
(self
, tag
=None
, startpos
=None
, endpos
=None
, obj
=None
):
def _repr
(self
):
def _repr_pretty
(self
, p
):
def eval
(self
, context
):
def _str
(self
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
class Template
(Block
):
A template object is normally created by passing the template source to the
constructor. It can also be loaded from the compiled format via the class
methods load
(from a stream) or loads
(from a string).
The compiled format can be generated with the methods dump
(which
dumps the format to a stream) or dumps
(which returns a string with
the compiled format).
Rendering the template can be done with the methods render
(which
is a generator) or renders
(which returns a string).
A Template
can also be called as a function (returning the result
of the first <?return?>
tag encountered). In this case all output of the
template will be ignored.
A Template
object is itself an AST node. Evaluating it will store
the template object under its name in the local variables.
def __init__
(self
, source
=None
, name
=None
, whitespace
='keep'
, startdelim
='<?'
, enddelim
='?>'
, signature
=None
):
Create a Template
object.
If source
is None
, the Template
remains uninitialized,
otherwise source
will be compiled (using startdelim
and
enddelim
as the tag delimiters).
name
is the name of the template. It will be used in exception
messages and should be a valid Python identifier.
whitespace
specifies how whitespace is handled in the literal text
in templates (i.e. the text between the tags):
"keep"
Whitespace is kept as it is.
"strip"
Strip linefeeds and the following indentation from the text. However trailing whitespace at the end of the line will still be honored.
"smart"
If a line contains only indentation and one tag that isn't a
print
orprintx
tag, the indentation and the linefeed after the tag will be stripped from the text. Furthermore the additional indentation that might be introduced by afor
,if
,elif
,else
ordef
block will be ignored. So for example the output of:<?code langs = ["Python", "Java", "Javascript"]?> <?if langs?> <?for lang in langs?> <?print lang?> <?end for?> <?end if?>
will simply be:
Python Java Javascript
without any additional empty lines or indentation.
(Output will always be ignored when calling a template as a function.)
signature
is the signature of the template. For a top level
template it can be:
None
The template will accept all keyword arguments.
- An
inspect.Signature
object This signature will be used as the signature of the template.
- A callable
The signature of the callable will be used.
- A string
The signature as a string, i.e. something like
"x, y=42, *args, **kwargs"
. This string will be parsed and evaluated to create the signature for the template.
If the template is a subtemplate (i.e. a template defined by another
template via <?def t?>...<?end def?>
), signature
can be:
None
The template will accept all arguments.
- A
Signature
object This AST node will be evaluated at the point of definition of the subtemplate to create the final signature of the subtemplate.
def _repr
(self
):
def _repr_pretty
(self
, p
):
def _str
(self
):
def ul4getattr
(self
, name
):
def ul4ondump
(self
, encoder
):
def ul4onload
(self
, decoder
):
def dump
(self
, stream
):
dump
dumps the template/function in compiled UL4ON format to the
stream stream
.
def dumps
(self
):
dumps
returns the template/function in compiled UL4ON format
(as a string).
def _renderbound
(self
, context
):
def ul4render
(*args
, **kwargs
):
def render
(*args
, **kwargs
):
Render the template iteratively (i.e. this is a generator).
args[1:]
and kwargs
contain the top level variables available
to the template code. (args[0]
is the self
parameter, but
render
is defined in this way, to allow a keyword argument named
self
).
def _rendersbound
(self
, context
):
def ul4renders
(*args
, **kwargs
):
def renders
(*args
, **kwargs
):
Render the template as a string. vars
contains the top level
variables available to the template code.
def _callbound
(self
, context
):
def ul4call
(*args
, **kwargs
):
Call the template as a function and return the resulting value.
vars
contains the top level variables available to the template code.
def __call__
(*args
, **kwargs
):
Call the template as a function and return the resulting value.
vars
contains the top level variables available to the template code.
def jssource
(self
):
Return the template as the source code of a Javascript function.
def javasource
(self
):
Return the template as Java source code.
def _tokenize
(self
, source
, startdelim
, enddelim
):
Tokenize the template/function source code source
into tags and
non-tag text. startdelim
and enddelim
are used as the tag
delimiters.
This is a generator which produces Text
/Tag
objects
for each tag or non-tag text. It will be called by _compile
internally.
def _tags2lines
(self
, tags
):
Transforms an iterable of tags into an iterable of lines by splitting the literal text between the tags into lines.
A line is a list of nodes and will start with an Indent
node
(containing the indenting whitespace if the line is indented, or an empty
indentation if it isn't) and might end with a LineEnd
node
(containing the line feed if the line is terminated (which most lines
(except maybe the last one) are)).
def _whitespace_keep
(self
, lines
):
def _whitespace_strip
(self
, lines
):
def _whitespace_smart
(self
, lines
):
def _parser
(self
, tag
, error
):
def _parsesignature
(self
, tag
):
def _compile
(self
, source
, name
, startdelim
, enddelim
):
Compile the template source code source
into an AST.
startdelim
and enddelim
are used as the tag delimiters.
def eval
(self
, *args
, **kwargs
):
class Signature
(Code
):
AST node for the signature of a template.
The list of arguments is found in params
.