How to use Gutt
Command-line interface (CLI)#
Install Gutt:
npm i gutt-cli
Install stringifier for your platform. Full list can be found here.
Let’s assume you want to create PHP templates for server rendering.
NOTICE: Not every stringifier supports CLI. Sometime you'll have to write a bit complicated scripts.
npm i gutt-php-stringifier
First of all, you need to specify your templates files, stringifier's name and the output path:
npx gutt templates/*.gutt -s php-stringifier -o dist/server-templates
TIP: It can be useful to add this command to your npm-run scripts.
Templates may be located in multiple folders. Just list them all.
npx gutt templates/*.gutt components/**/*.{tmplt,gutt} -s php-stringifier -o dist/server-templates
For source file with path templates/header.gutt
, output file
will be dist/server-templates/templates/header.gutt.php
.
To ignore directory structure of source files, use --cwd
:
npx gutt templates/*.gutt components/**/*.{tmplt,gutt} --cwd templates -s php-stringifier -o dist/server-templates
With --cwd templates
option output file for template above will be
dist/server-templates/header.gutt.php
. You can specify multiple --cwd
options.
Gutt is aimed to make reusable templates. If you want to transpile to multiple platforms you can specify multiple stringifiers.
npx gutt templates/*.gutt -s php-stringifier -o dist/php -s browser-stringifier -o dist/browser
Don’t forget to install stringifiers first. And don’t forget to drop gutt-
prefix
when you will use them.
You can always see complete list of options in the help:
npx gutt --help