zwig/zwig

Zwig converts Twig templates into executable JavaScript

v0.1.6 2016-09-16 11:06 UTC

This package is not auto-updated.

Last update: 2022-09-03 08:11:21 UTC


README

Build Status Code Quality Latest Version Software License

What is Zwig?

Zwig is a toolkit that uses Twig to convert Twig templates into JavaScript, so that they can be used for client-side rendering within any modern browser.

Zwig has the following goals:

  • compatible with Twig as far as possible
  • fast and secure client-side rendering
  • easy integration into both PHP and JS environments

Please note that this project is in a very early state and therefore not mature enough for production. The current status is listed within the documentation.

Getting started

Install Zwig via Composer:

composer require zwig/zwig

Convert templates:

./vendor/bin/zwig convert vendor/zwig/zwig/examples

Start using them:

<!DOCTYPE html>
<html>
    <body>
        <script src="vendor/zwig/zwig/dist/zwig.min.js"></script>
        <script src="vendor/zwig/zwig/examples/hello.js"></script>
        <script>
            document.write(Zwig.render('hello.twig', {
                name: 'GitHub'
            });
        </script>
    </body>
</html>

Check the directory vendor/zwig/zwig/examples for more examples.

More information