Templating API reference

Overview

When creating a Yellicode template, you will always need to import this API, which can be found in the the @yellicode/templating NPM package. It contains the basic templating infrastructure, as well as utilities and base classes for creating custom code writers and model transforms.

Interfaces

CodeGenerationOptions Defines the options for generating a code file with the CodeGenerator.
CodeGenerator The primary interface for code generation using a template. An instance can be obtained by importing the exported "Generator" constant into the template.
CodeModelOptions Defines the options for retrieving a model to be used as input for code generation.
ModelBasedCodeGenerationOptions Combines the CodeGenerationOptions and CodeModelOptions for the generateFromModel function.
ModelTransform The base interface for all model transformations.
RegionMarkerFormatter Represents a class that formats file region names into a start- and end marker string. These markers are used to embed parts of other files (regions) in the generated code.
TextWriter Represents a writer that can write a sequential series of characters.
TypeNameProvider Defines the interface for classes that determine type names for types in a model. This interface is typically implemented by language-specific code generators, which may need to convert the name of a model type to the name used by the programming lanugage. For example: a decimal, float or integer in a model should result in a type named 'number' when generating TypeScript code. This interface is implemented by the DefaultTypeNameProvider, which can be extended to provide language-specific type names.

Classes

CodeWriterUtility Contains helper methods that can be used by custom code writers and templates.
CodeWriter The abstract base class for all code writers. This writer implements the TextWriter interface by decorating the TextWriter provided in the constructor.
ModelTransformPipeline Performs a sequence of model transforms, where the output of each transform is the input of the next transform.
NameUtility Provides helper functions for converting names.
PackageFilterTransform Transforms a Model or Package by returning just the Package that matches a specified expression.
PackagedElementTransform A base class for transforms that need to be applied recursively to all nested packaged elements in a model or package.
CapitalizingTransform A transform that capitalizes its rename targets, that is, makes the first character uppercase.
LowerToUpperCamelCaseTransform A transform that converts its rename targets from lowerCamelCase to UpperCamelCase.
PrefixingTransform A transform that adds a prefix to its rename targets.
RenamingTransform A base class for renaming classes, interfaces, properties, operations parameters, enumerations and enumeration literals.
SuffixingTransform A transform that adds a suffix to its rename targets.
UnCapitalizingTransform A transform that uncapitalizes its rename targets, that is, makes the first character lowercase.
UpperToLowerCamelCaseTransform A transform that converts its rename targets from UpperCamelCase to lowerCamelCase.
DefaultTypeNameProvider Default implementation of the TypeNameProvider interface. This implementation returns type names as-is, but allows inheritors to provide their own implementation by overriding getTypeNameForType and/or getTypeNameForTypedElement.

Enumerations

OutputMode
RenameTargets Enumerates which element types to be renamed when performing rename transforms.