How to use the velocityjs.parse function in velocityjs

To help you get started, we’ve selected a few velocityjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github syndesisio / syndesis / app / ui-react / packages / ui / src / Shared / TextEditor / velocity-lint.ts View on Github external
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;
  }
github syndesisio / syndesis / app / ui-react / packages / ui / src / Shared / TextEditor / velocity-lint.ts View on Github external
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),
        });
      }
github aws-amplify / amplify-cli / packages / amplify-velocity-template / examples / app.js View on Github external
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;

velocityjs

Velocity Template Language(VTL) for JavaScript

MIT
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis