Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public parse(content: string): TemplateSymbol[] {
const symbols: TemplateSymbol[] = [];
const tokens: any[] = Velocity.parse(content);
for (const token of tokens) {
if (token.type === 'references') {
symbols.push(new TemplateSymbol(token.id, 'string'));
}
}
return symbols;
}
protected validate(text: string, errors: any[]): void {
try {
const tokens: any[] = Velocity.parse(text);
let totalSymbols = 0;
for (const token of tokens) {
if (token.type === 'references') {
totalSymbols++;
}
}
if (totalSymbols === 0) {
const msg = 'linter-no-symbols';
errors.push({
from: CodeMirror.Pos(0, 0),
message: msg,
severity: 'warning',
to: CodeMirror.Pos(0, 0),
});
}
import { parse, Compile } from 'velocityjs';
const asts = parse(document.querySelector('#tmpl').innerHTML);
const data = {
items: [{ a: '1' }, { a: 'successed' }],
};
const s = new Compile(asts).render(data);
document.querySelector('.foo').innerHTML = s;