API reference¶
-
class
lina.Formatter(formatterType)[source]¶ Bases:
objectBase class for all formatters.
A formatter can be used to transform blocks/values during expansion.
-
class
lina.FormatterType[source]¶ Bases:
enum.EnumThe formatter type, either
BlockorValue.-
Block= 0¶
-
Value= 1¶
-
-
exception
lina.InvalidBlock(message, position)[source]¶ Bases:
lina.TemplateExceptionAn invalid block was encountered.
-
exception
lina.InvalidFormatter(message, position)[source]¶ Bases:
lina.TemplateExceptionAn invalid formatter was encountered.
This exception is raised when a formatter could not be found or instantiated.
-
exception
lina.InvalidNamedCharacterToken(message, position)[source]¶ Bases:
lina.InvalidWhitespaceTokenAn invalid named character token was encountered.
-
exception
lina.InvalidToken(message, position)[source]¶ Bases:
lina.TemplateExceptionAn invalid token was encountered.
-
exception
lina.InvalidWhitespaceToken(message, position)[source]¶ Bases:
lina.TemplateExceptionOnly for backwards compatibility. Will be removed in 2.x.
-
class
lina.Template(template, includeHandler=None, *, filename=None)[source]¶ Bases:
objectThe main template class.
-
RenderSimple(**items)[source]¶ Simple rendering function.
This is just a convenience function which creates the context from the passed items and forwards them to
Template.Render().
-
-
exception
lina.TemplateException(message, position)[source]¶ Bases:
ExceptionBase class for all exceptions thrown by Lina.
-
class
lina.TemplateRepository(templateDirectory, suffix='')[source]¶ Bases:
lina.IncludeHandlerA file template repository.
This template repository will load files from a specified folder.
-
class
lina.TextStream(text, *, filename=None)[source]¶ Bases:
objectA read-only text stream.
The text stream is used for input only and keeps track of the current read pointer position in terms of line/column numbers.
-
class
lina.Token(name, start, end, position)[source]¶ Bases:
objectRepresents a single token.
Each token may contain an optional list of flags, separated by colons. The grammar implemented here is:
[prefix]?[^:}]+(:[^:})+, for example: {{#Foo}} -> name = Foo, prefix = # {{Bar:width=8}} -> name = Bar, prefix = None, flags = {width:8}The constructor checks if the formatter matches the token type. A block formatter can be only applied to a block token, and a value formatter only to a value.