@tarik02/bladejs-compiler
v3.0.0
Published
Laravel's blade templating engine for JavaScript and TypeScript.
Downloads
6
Readme
bladejs-compiler
Installation
$ yarn add @tarik02/bladejs-compiler
# or
$ npm install --save @tarik02/bladejs-compiler
Usage
import {
AbstractError,
Compiler,
Source,
} from '@tarik02/bladejs-compiler';
const compiler = new Compiler();
compiler.addDefaults();
const source = `
<div class="alert alert-danger">
<div class="alert-title">{{ title }}</div>
{{ slot }}
</div>
`.trim();
const filename = 'test.bjs';
const source = new Source(source, filename);
let compiled: string;
try {
compiled = compiler.compile(source);
} catch (e) {
if (e instanceof AbstractError) {
process.stdout.write(e.prettyPrint());
process.exit(-1);
}
throw e;
}