Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @tarik02/bladejs-compiler with all npm packages installed. Try it out:

var bladejsCompiler = require("@tarik02/bladejs-compiler")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@tarik02/bladejs-compiler v2.2.0

Laravel's blade templating engine for JavaScript and TypeScript.

bladejs-compiler

TravisCI Build Status AppVeyor Build Status npm version

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;
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free