# AST for <%= templateTag %>

You can use the type definition of this AST:


export function create(context) {
    const microTemplateService = context.parserServices.getMicroTemplateService()
    return {
        "Program:exit"() {
            microTemplateService.traverseMicroTemplates({
                MicroTemplateEvaluate(node: MicroTemplateEvaluate): void {
                    // ...
                },
                MicroTemplateInterpolate(node: MicroTemplateInterpolate): void {
                    // ...
                },
                MicroTemplateEscape(node: MicroTemplateEscape): void {
                    // ...
                },
            })
        },
    }
}

See details: https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/master/lib/ast/micro-template-nodes.js

# Token

extend interface Token {
    range: [ number ]
}
  • The range property is an array which has 2 integers. The 1st integer is the offset of the start location of the node. The 2nd integer is the offset of the end location of the node.

# Node

extend interface Node {
    range: [ number ]
}
  • The range property is an array which has 2 integers. The 1st integer is the offset of the start location of the node. The 2nd integer is the offset of the end location of the node.

# MicroTemplateEvaluate

interface MicroTemplateEvaluate <: Node {
    type: "MicroTemplateEvaluate",
    expressionStart: MicroTemplateExpressionStart,
    expressionEnd: MicroTemplateExpressionEnd,
    code: string
}
  • This is a template tag that is evaluated as script.
  • The start tag information is stored in the expressionStart property.
  • The end tag information is stored in the expressionEnd property.

# MicroTemplateInterpolate

interface MicroTemplateInterpolate <: Node  {
    type: "MicroTemplateInterpolate",
    expressionStart: MicroTemplateExpressionStart,
    expressionEnd: MicroTemplateExpressionEnd,
    code: string
}
  • This is a template tag that is interpolate as template.
  • The start tag information is stored in the expressionStart property.
  • The end tag information is stored in the expressionEnd property.

# MicroTemplateEscape

interface MicroTemplateInterpolate <: Node  {
    type: "MicroTemplateEscape",
    expressionStart: MicroTemplateExpressionStart,
    expressionEnd: MicroTemplateExpressionEnd,
    code: string
}
  • This is a template tag that is escapes to interpolate as template.
  • The start tag information is stored in the expressionStart property.
  • The end tag information is stored in the expressionEnd property.

# MicroTemplateExpressionStart

interface MicroTemplateExpressionStart <: Token  {
    type: "MicroTemplateExpressionStart",
    chars: string
}
  • This is the start tag of the template tag.
  • The delimiter string is stored in the chars property.

# MicroTemplateExpressionEnd

interface MicroTemplateExpressionEnd <: Token  {
    type: "MicroTemplateExpressionEnd",
    chars: string
}
  • This is the end tag of the template tag.
  • The delimiter string is stored in the chars property.