TemplatesParser class

LG Parser

Properties

importRegex

Import regex.

inlineContentId

Inline text id.

optionRegex

option regex.

Methods

antlrParseTemplates(LGResource)

Parse LG content and return the AST.

defaultFileResolver(LGResource, string)

Default import resolver, using relative/absolute file path to access the file content.

parseFile(string, ImportResolverDelegate, ExpressionParser)

Parse a file and return LG file.

parseResource(LGResource, ImportResolverDelegate, ExpressionParser)

Parser to turn lg content into a Templates.

parseText(string, string, ImportResolverDelegate, ExpressionParser)

Parser to turn lg content into a Templates.

parseTextWithRef(string, Templates)

Parser to turn lg content into a Templates based on the original Templates.

Property Details

importRegex

Import regex.

static importRegex: RegExp = new RegExp(/\[([^\]]*)\]\(([^)]*)\)([\w\s]*)/)

Property Value

RegExp

inlineContentId

Inline text id.

static inlineContentId: string = "inline content"

Property Value

string

optionRegex

option regex.

static optionRegex: RegExp = new RegExp(/>\s*!#(.*)$/)

Property Value

RegExp

Method Details

antlrParseTemplates(LGResource)

Parse LG content and return the AST.

static function antlrParseTemplates(resource: LGResource): FileContext

Parameters

resource
LGResource

LG resource.

Returns

The abstract syntax tree of lg file.

defaultFileResolver(LGResource, string)

Default import resolver, using relative/absolute file path to access the file content.

static function defaultFileResolver(resource: LGResource, resourceId: string): LGResource

Parameters

resource
LGResource

Original Resource.

resourceId

string

Import path.

Returns

Accessed lg resource.

parseFile(string, ImportResolverDelegate, ExpressionParser)

Parse a file and return LG file.

static function parseFile(filePath: string, importResolver?: ImportResolverDelegate, expressionParser?: ExpressionParser): Templates

Parameters

filePath

string

LG absolute file path..

importResolver
ImportResolverDelegate

Resolver to resolve LG import id to template text.

expressionParser

ExpressionParser

Expression parser for evaluating expressions.

Returns

New lg file.

parseResource(LGResource, ImportResolverDelegate, ExpressionParser)

Parser to turn lg content into a Templates.

static function parseResource(resource: LGResource, importResolver?: ImportResolverDelegate, expressionParser?: ExpressionParser): Templates

Parameters

resource
LGResource

LG resource.

importResolver
ImportResolverDelegate

Resolver to resolve LG import id to template text.

expressionParser

ExpressionParser

Expression parser for evaluating expressions.

Returns

Entity.

parseText(string, string, ImportResolverDelegate, ExpressionParser)

Warning

This API is now deprecated.

This method will soon be deprecated. Use ParseResource instead.

Parser to turn lg content into a Templates.

static function parseText(content: string, id: string, importResolver?: ImportResolverDelegate, expressionParser?: ExpressionParser): Templates

Parameters

content

string

Text content contains lg templates.

id

string

Id is the identifier of content. If importResolver is undefined, id must be a full path string.

importResolver
ImportResolverDelegate

Resolver to resolve LG import id to template text.

expressionParser

ExpressionParser

Expression parser for evaluating expressions.

Returns

Entity.

parseTextWithRef(string, Templates)

Parser to turn lg content into a Templates based on the original Templates.

static function parseTextWithRef(content: string, originalTemplates: Templates): Templates

Parameters

content

string

Text content contains lg templates.

originalTemplates
Templates

Original templates.

Returns

Template containing lg content.