Flutter Engine
The Flutter Engine
|
Public Member Functions | |
def | __init__ (self, bindings=None) |
def | EmitRaw (self, item) |
def | Emit (self, template_source, **parameters) |
def | Fragments (self) |
def | Bind (self, var, template_source, **parameters) |
An Emitter collects string fragments to be assembled into a single string.
Definition at line 20 of file emitter.py.
def scripts.emitter.Emitter.__init__ | ( | self, | |
bindings = None |
|||
) |
Definition at line 24 of file emitter.py.
def scripts.emitter.Emitter.Bind | ( | self, | |
var, | |||
template_source, | |||
** | parameters | ||
) |
Adds a binding for var to this emitter.
Definition at line 131 of file emitter.py.
def scripts.emitter.Emitter.Emit | ( | self, | |
template_source, | |||
** | parameters | ||
) |
Emits a template, substituting named parameters and returning emitters to fill the named holes. Ordinary substitution occurs at $NAME or $(NAME). If there is no parameter called NAME, the text is left as-is. So long as you don't bind FOO as a parameter, $FOO in the template will pass through to the generated text. Substitution of $?NAME and $(?NAME) yields an empty string if NAME is not a parameter. Values passed as named parameters should be strings or simple integral values (int or long). Named holes are created at $!NAME or $(!NAME). A hole marks a position in the template that may be filled in later. An Emitter is returned for each named hole in the template. The holes are filled by emitting to the corresponding emitter. Subtemplates can be created by using $#NAME(...), where text can be placed inside of the parentheses and will conditionally expand depending on if NAME is set to True or False. The text inside the parentheses may use further $#NAME and $NAME substitutions, but is not permitted to create holes. Emit returns either a single Emitter if the template contains one hole or a tuple of emitters for several holes, in the order that the holes occur in the template. The emitters for the holes remember the parameters passed to the initial call to Emit. Holes can be used to provide a binding context.
Definition at line 32 of file emitter.py.
def scripts.emitter.Emitter.EmitRaw | ( | self, | |
item | |||
) |
Emits literal string with no substitution.
Definition at line 28 of file emitter.py.
def scripts.emitter.Emitter.Fragments | ( | self | ) |
Returns a list of all the string fragments emitted.
Definition at line 94 of file emitter.py.