twing
TypeScript icon, indicating that this package has built-in type declarations

7.0.0-beta.3 • Public • Published

Twing

NPM version Build Status Coverage percentage Donate

First-class JavaScript Twig compiler

Prerequisites

Twing needs at least node.js 16.0.0 to run.

Installation

The recommended way to install Twing is via npm:

npm install twing --save

Documentation

See the Twing website for documentation.

Basic API Usage

import {createEnvironment, createArrayLoader} from "twing";

const loader = createArrayLoader({
    'index.twig': 'Everybody loves {{ name }}!'
});

const environment = createEnvironment(loader);

environment.render('index.twig', {name: 'Twing'}).then((output) => {
    // output contains "Everybody loves Twing!"
});

Script tag

Use jsdelivr CDN to include Twing in your HTML document:

<script src="https://cdn.jsdelivr.net/npm/twing/dist/lib.min.js"></script>

Once loaded by the browser, Twing is available under the global Twing variable.

Related packages

  • gulp-twing: Compile Twig templates with gulp. Build upon Twing.
  • twing-loader: Webpack loader that compiles Twig templates using Twing.

License

Copyright © 2018 Eric MORAND. Released under the 2-Clause BSD License.

Package Sidebar

Install

npm i twing

Weekly Downloads

5,214

Version

7.0.0-beta.3

License

BSD-2-Clause

Unpacked Size

1.42 MB

Total Files

576

Last publish

Collaborators

  • ericmorand