diff --git a/src/tokenizer/chars.ts b/src/tokenizer/chars.ts index 5f428c3..6a5d19a 100644 --- a/src/tokenizer/chars.ts +++ b/src/tokenizer/chars.ts @@ -1,4 +1,4 @@ -import { Range } from "../types"; +import { Range, TemplateTokenType } from "../types"; export enum CharsType { HTML = "HTML", @@ -11,6 +11,7 @@ export class Chars { public isTemplate: boolean; constructor( public type: CharsType, + public templateTokenType: TemplateTokenType = TemplateTokenType.Inline, public value: string, public range: Range, public wrapper?: { diff --git a/src/tokenizer/source-code.ts b/src/tokenizer/source-code.ts index da3c41a..e875f0a 100644 --- a/src/tokenizer/source-code.ts +++ b/src/tokenizer/source-code.ts @@ -55,9 +55,10 @@ export class SourceCode { charsList.push( new Chars( CharsType.Template, + info.type, this.source.slice(range[0], range[1]), [range[0], range[1]], - Array.isArray(info) ? undefined : info + info ) ); templateInfoIndex++; @@ -66,7 +67,7 @@ export class SourceCode { } } charsList.push( - new Chars(CharsType.HTML, this.source[sourceIndex], [ + new Chars(CharsType.HTML, undefined, this.source[sourceIndex], [ sourceIndex, sourceIndex + 1, ]) diff --git a/src/types/template.ts b/src/types/template.ts index 9d5065a..e28e53c 100644 --- a/src/types/template.ts +++ b/src/types/template.ts @@ -1,8 +1,16 @@ import { Range } from "./range"; -export type TemplateInfo = - | Range - | { - open: Range; - close: Range; - }; +export enum TemplateTokenType { + Inline = "inline", + BlockOpen = "blockOpen", + BlockClose = "blockClose", + ConditionalBlockOpen = "conditionalBlockOpen", + ConditionalBlockClose = "conditionalBlockClose", + AlternativeBlockOpen = "alternativeBlockOpen", +} + +export type TemplateInfo = { + type?: TemplateTokenType; + open: Range; + close: Range; +};