template_engine library

Classes

ArgumentDefaultExpression
ArgumentExpression
ArgumentExpressionList
ArgumentExpressionList is the result after parsing. It is not yet validated because the parameters may not be known at parsing.
ArgumentExpressionMap
Validates and maps a parsed ArgumentExpressionList to parameter names and expressions
AssignmentNode
AstNode
BinaryOperatorDefinition
Defines a binary operator, including its parsing and evaluation behavior.
BinaryOperatorDocumentation
Provides Markdown documentation for a binary operator.
BinaryOperatorExpression
Represents a operator expression consisting of a left and right operand and an operator symbol (e.g. +, ==, &&).
BinaryOperatorSignature<LEFT_OPERAND_TYPE, RIGHT_OPERAND_TYPE, RESULT_TYPE>
Describes a single valid type combination ("signature") for a binary operator.
CodeBlockDelimiter
CodeToken
A single lexical token produced during tokenization.
CodeTokenStream
A stream abstraction over a list of CodeTokens, providing utilities for tokenization, lookahead, and sequential consumption.
CommentNode
A template comment that produces no rendered output.
ConstantDefinition<T>
A ConstantDefinition is a value that does not change value over time.
ConstantDocumentation<T>
DataTypeDefinition
A data type defines what the possible values an expression, such as a variable, operator or a function call, might use.
DefinitionDocumentation
DocumentationFunction
DocumentationProvider
ErrorNode
A node used when a code block could not be parsed.
Example
ExampleProvider
Expression
ExpressionBlockExample
ExpressionBlockNode
A node that evaluates and renders an expression.
ExpressionParser
FileTemplate
A template loaded from a local file.
ForEachNode
A node that renders its body for each item in an iterable or map.
ForNode
A node that renders its body for each integer in an inclusive range.
FunctionCallContext
FunctionCallExpression
FunctionDefinition<RETURN_TYPE>
A function is a piece of dart code that performs a specific task.
FunctionDefinitionDocumentation<RETURN_TYPE>
FunctionDefinitionDocumentation2<RETURN_TYPE>
FunctionGroup
Grammar
Defines the TemplateEngine syntax, which can be customized by providing a custom Grammar to the TemplateEngine constructor.
HtmlTableRow
HtmlTableWriter
IfNode
A conditional node with separate branches for true and false conditions.
ImportedTemplate
A template created from source and text already loaded by an import.
ListExpression
LiteralExpression
MapExpression
MapPropertyExpression
MarkdownDocumentation
MethodCallContext<OWNER_TYPE>
MethodCallExpression
MethodDefinition<OWNER_TYPE, RETURN_TYPE>
A method is a piece of dart code that performs a specific operation on a given object (the method owner). So a method can basically do anything that dart code can do.
MethodSignatureDocumentation
NamedArgumentExpression
Parameter<T>
A FunctionDefinitions or MethodDefinitions can have 0 or more Parameters. A Parameter:
ParseResult
PositionalArgumentExpression
Presence
PresenceMandatory
PresenceOptional
PresenceOptionalWithDefaultValue
RenderContext
Holds mutable state shared while rendering a parsed template.
RenderResult
The result of rendering one template.
RenderResults
A class that represents the result of rendering multiple templates. The results of rendering multiple templates with shared state.
SetExpression
StatementDefinition
SyntaxDocumentation
Template
A Template is a text that can be parsed by the TemplateEngine.
TemplateBlock
A section of template source text that touches/borders to another without any gap.
TemplateDocument
The parsed representation of a template and its syntax tree.
TemplateEngine
The TemplateEngine can:
TemplateLocation
A one-based line and column location in template source.
TemplateParser
Default implementation of a template parser that transforms raw template text into an abstract syntax tree (AST).
TemplateParserDelegate
Defines the contract used by delegate parsers to interact with the surrounding template parsing process.
TemplateRenderResult
The rendered text and errors shared by single- and multi-template results.
TestFileExample
TextNode
A node containing literal template text.
TextTemplate
A template whose source and contents are provided as text.
TitleLevelParameter
UnaryOperatorDefinition
UnaryOperatorDocumentation
Provides Markdown documentation for a unary operator.
UnaryOperatorExpression
Represents a unary operator expression, consisting of a single operand and an operator symbol (e.g. !, -).
UnaryOperatorSignature<OPERAND_TYPE, RESULT_TYPE>
Describes a single valid type combination ("signature") for a unary operator.
UriTemplate
A template loaded from a URI.
Variable
A variable is a named container for some type of information (like num, bool, String etc...)
VariableExpression
VariableValue
VariableValues must be one of the following types:
WhileNode
A node that repeatedly renders its body while a condition is truthy.

Enums

BinaryOperatorAssociativity
the associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. If an operand is both preceded and followed by operators, and those operators have equal precedence, then the operand may be used as input to two different operations (i.e. the two operations indicated by the two operators). The choice of which operations to apply the operand to, is determined by the associativity of the operators.
BinaryOperatorPrecedence
Defines precedence levels for binary operators used during expression parsing.
CellType
ParameterOwner
TokenType

Properties

aCosFunction → FunctionDefinition<num>
final
addOperator → BinaryOperatorDefinition
final
andOperator → BinaryOperatorDefinition
final
aSinFunction → FunctionDefinition<num>
final
assignStatement → StatementDefinition
final
aTanFunction → FunctionDefinition<num>
final
codeBlockDocumentation → DocumentationFunction
final
commentStatement → StatementDefinition
final
constantDocumentation → DocumentationFunction
final
cosFunction → FunctionDefinition<num>
final
customConstantExample → TestFileExample
final
customDataTypeExample → TestFileExample
final
customFunctionExample → TestFileExample
final
customMethodExample → TestFileExample
final
customOperatorExample → TestFileExample
final
customStatementExample → TestFileExample
final
dataTypeDocumentation → DocumentationFunction
final
divideOperator → BinaryOperatorDefinition
final
endsWithMethod → MethodDefinition<String, bool>
final
equalsOperator → BinaryOperatorDefinition
final
exampleDocumentation → DocumentationFunction
final
expFunction → FunctionDefinition<num>
final
exponentOperator → BinaryOperatorDefinition
final
forEachStatement → StatementDefinition
final
forStatement → StatementDefinition
final
functionDocumentation → DocumentationFunction
final
greaterThanOperator → BinaryOperatorDefinition
final
greaterThanOrEqualsOperator → BinaryOperatorDefinition
final
ifStatement → StatementDefinition
final
importJson → FunctionDefinition
final
importPure → FunctionDefinition
final
importTemplate → FunctionDefinition
final
importXml → FunctionDefinition
final
importYaml → FunctionDefinition
final
indexOfMethod → MethodDefinition<String, int>
final
isTemplateEngineProject → bool
no setter
lengthMethod → MethodDefinition<String, num>
final
lessThanOperator → BinaryOperatorDefinition
final
lessThanOrEqualsOperator → BinaryOperatorDefinition
final
logFunction → FunctionDefinition<num>
final
methodDocumentation → DocumentationFunction
final
minusPreFixOperator → UnaryOperatorDefinition
final
moduloOperator → BinaryOperatorDefinition
final
multiplyOperator → BinaryOperatorDefinition
final
notEqualsOperator → BinaryOperatorDefinition
final
notPreFixOperator → UnaryOperatorDefinition
final
operatorDocumentation → DocumentationFunction
final
orOperator → BinaryOperatorDefinition
final
padLeftMethod → MethodDefinition<String, String>
final
padRightMethod → MethodDefinition<String, String>
final
plusPreFixOperator → UnaryOperatorDefinition
final
replaceAllMethod → MethodDefinition<String, String>
final
replaceFirstMethod → MethodDefinition<String, String>
final
roundFunction → FunctionDefinition<num>
final
sinFunction → FunctionDefinition<num>
final
splitMethod → MethodDefinition<String, List<String>>
final
sqrtFunction → FunctionDefinition<num>
final
standardAdditiveOperators → List<BinaryOperatorDefinition>
final
standardAndOperators → List<BinaryOperatorDefinition>
final
standardBinaryOperators → List<BinaryOperatorDefinition>
final
standardConstants → List<ConstantDefinition>
final
standardDataTypes → List<DataTypeDefinition>
final
standardDocumentationFunctions → FunctionGroup
Functions that create documentation of the TemplateEngine configuration
final
standardDoubleMethods → List<MethodDefinition<double, dynamic>>
final
standardDynamicMethods → List<MethodDefinition>
final
standardEqualityOperators → Set<BinaryOperatorDefinition>
final
standardExponentiationOperators → List<BinaryOperatorDefinition>
final
standardFunctionGroups → List<FunctionGroup>
final
standardImportFunctions → FunctionGroup
final
standardIntMethods → List<MethodDefinition<int, dynamic>>
final
standardListMethods → List<MethodDefinition<List, dynamic>>
final
standardMapMethods → List<MethodDefinition<Map, dynamic>>
final
standardMathFunctions → FunctionGroup
final
standardMethods → List<MethodDefinition>
final
standardMultiplicativeOperators → List<BinaryOperatorDefinition>
final
standardNumberMethods → List<MethodDefinition<num, dynamic>>
final
standardOrOperators → List<BinaryOperatorDefinition>
final
standardRelationalOperators → List<BinaryOperatorDefinition>
final
standardSetMethods → List<MethodDefinition<Set, dynamic>>
final
standardStatements → List<StatementDefinition>
final
standardStringMethods → List<MethodDefinition<String, dynamic>>
final
standardTemplateFunctions → FunctionGroup
final
standardUnaryOperators → List<UnaryOperatorDefinition>
final
standardXorOperators → List<BinaryOperatorDefinition>
final
startsWithMethod → MethodDefinition<String, bool>
final
subStringMethod → MethodDefinition<String, String>
final
subtractOperator → BinaryOperatorDefinition
final
tanFunction → FunctionDefinition<num>
final
templateSourceFunction → FunctionDefinition
final
toCamelCaseMethod → MethodDefinition<String, String>
final
toConstantCaseMethod → MethodDefinition<String, String>
final
toDotCaseMethod → MethodDefinition<String, String>
final
toHeaderCaseMethod → MethodDefinition<String, String>
final
toLowerCaseMethod → MethodDefinition<String, String>
final
toNumberMethod → MethodDefinition<String, num>
final
toParamCaseMethod → MethodDefinition<String, String>
final
toPascalCaseMethod → MethodDefinition<String, String>
final
toPathCaseMethod → MethodDefinition<String, String>
final
toSentenceCaseMethod → MethodDefinition<String, String>
final
toSnakeCaseMethod → MethodDefinition<String, String>
final
toStringMethod → MethodDefinition<dynamic, String>
final
toTitleCaseMethod → MethodDefinition<String, String>
final
toUpperCaseMethod → MethodDefinition<String, String>
final
trimLeftMethod → MethodDefinition<String, String>
final
trimMethod → MethodDefinition<String, String>
final
trimRightMethod → MethodDefinition<String, String>
final
typeMethod → MethodDefinition<dynamic, String>
final
variableDocumentation → DocumentationFunction
final
variableExamples → List<TestFileExample>
final
whileStatement → StatementDefinition
final
xorOperator → BinaryOperatorDefinition
final

Functions

aggregatedCodeBlockDocumentation(Grammar grammar, int titleLevel) → String
aggregatedConstantDocumentation(Grammar grammar, int titleLevel) → String
aggregatedDataTypeDocumentation(Grammar grammar, int titleLevel) → String
aggregatedFunctionDocumentation(Grammar grammar, int titleLevel) → String
aggregatedMethodDocumentation(Grammar grammar, int titleLevel) → String
aggregatedOperatorDocumentation(Grammar grammar, int titleLevel) → String
Provides aggregated Markdown documentation for all operators (both unary and binary) available in the template engine.
aggregatedParseErrorMessage(List<ParseError> errors) → String
Formats errors as an indented parse-error summary.
aggregatedRenderErrorMessage(List<RenderError> errors) → String
Formats errors as an indented render-error summary.
astNodesToString(List<AstNode> nodes, RenderContext context) → Future<String>
Renders nodes in order and concatenates their output.
createAggregatedErrorMessage(Template template, List<ParseError> parseErrors, List<RenderError> renderErrors, {bool imported = false}) → String
Creates a combined parse and render error message for template.
indentedLines(String indentation, String text) → String
Prefixes each line of text with indentation.
isHexadecimal(CodeToken token1, CodeToken token2) → bool
isTruthy(dynamic value) → bool
Converts a template value to the truthiness used by conditional nodes.
markdownTitle(int titleLevel, String title) → String
parameterAndArgumentDocumentation(int titleLevel, ParameterOwner owner) → String
readFromFilePath(String source) → Future<String>
Reads a file from a operation systems File Path/
readFromFileUri(Uri source) → Future<String>
Reads from a File URI scheme. This includes local files.
readFromHttpUri(Uri source) → Future<String>
readFromUri(Uri sourceUri) → Future<String>
readSource(String source) → Future<String>
source is a file path or a Uri.
renderFromContext(RenderContext context) → Future<RenderResult>
Renders every node in context and returns the collected result.
templateEngineExceptionsFromException(dynamic exception) → Iterable<TemplateEngineException>
Converts a thrown value into the template-engine errors it contains.
typeDescription(Type type) → String
validateIdentifier({required String nameType, required String nameToValidate}) → void

Typedefs

Arguments = Map<String, Object>
Arguments is a Map of parameter names and values
DataMap = Map<String, dynamic>
A DataMap is a structure that stores information with keys and values. The key is a name that identifies a value (case sensitive!) A value can is normally on of the following types:
VariableMap = DataMap
  • Variables are stored as key, value pairs in a dart Map<String, dynamic> where:
    • key=Variable name (case sensitive!)
    • value=Variable value
  • Variables can be used in an expression
  • Initial variable values are passed to the TemplateEngine.render method
  • Variables can be modified during rendering
  • Exceptions / Errors

    ArgumentTypeError
    FunctionException
    ImportError
    An error raised when rendering an imported template fails.
    InvalidIdentifierName
    MethodException
    MissingArgumentError
    ParseError
    An error encountered while parsing template source.
    PropertyException
    RenderError
    An error encountered while rendering a parsed template.
    TemplateEngineException
    VariableException