##// END OF EJS Templates
Added tag v1.3.2 for changeset 32db28d9ca07
Added tag v1.3.2 for changeset 32db28d9ca07

File last commit:

r82:025f02eff3b2 v1.3.0 default
r104:da978c4e697c default
Show More
TemplateParser.ts
72 lines | 1.5 KiB | video/mp2t | TypeScriptLexer
/ src / amd / ts / text / TemplateParser.ts
cin
working on support commonjs modules format
r59 import { argumentNotEmptyString } from "../safe";
import { MapOf } from "../interfaces";
cin
fixed "singleton" activation type handling in container configuration...
r65 import { TraceSource, DebugLevel } from "../log/TraceSource";
import m = require("module");
const trace = TraceSource.get(m.id);
cin
working on support commonjs modules format
r59
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 const splitRx = /(<%=|<%~|\[%~|\[%=|<%|\[%|%\]|%>)/;
cin
working on support commonjs modules format
r59
export enum TokenType {
None,
Text,
OpenInlineBlock,
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 OpenFilterBlock,
cin
working on support commonjs modules format
r59 OpenBlock,
CloseBlock
}
const tokenMap: MapOf<TokenType> = {
"<%": TokenType.OpenBlock,
"[%": TokenType.OpenBlock,
"<%=": TokenType.OpenInlineBlock,
"[%=": TokenType.OpenInlineBlock,
cin
StringBuilder, TextWriter, ConsoleWriter tests
r82 "<%~": TokenType.OpenFilterBlock,
"[%~": TokenType.OpenFilterBlock,
cin
working on support commonjs modules format
r59 "%>": TokenType.CloseBlock,
"%]": TokenType.CloseBlock
};
export interface ITemplateParser {
next(): boolean;
token(): TokenType;
value(): string;
}
export class TemplateParser implements ITemplateParser {
_tokens: string[];
_pos = -1;
_type: TokenType;
_value: string;
constructor(text: string) {
argumentNotEmptyString(text, "text");
this._tokens = text.split(splitRx);
this._type = TokenType.None;
}
next() {
this._pos++;
if (this._pos < this._tokens.length) {
this._value = this._tokens[this._pos];
this._type = tokenMap[this._value] || TokenType.Text;
cin
fixed "singleton" activation type handling in container configuration...
r65
cin
working on support commonjs modules format
r59 return true;
} else {
this._type = TokenType.None;
this._value = undefined;
return false;
}
}
token() {
return this._type;
}
value() {
return this._value;
}
}