zwig / zwig
Zwig converts Twig templates into executable JavaScript
Installs: 3 905
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.9
- symfony/console: >=3.0
- twig/twig: ~1.0
Requires (Dev)
- codeception/codeception: ^2.1
- codeception/phpbuiltinserver: ^1.2
- site5/phantoman: ^1.1
README
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.