Twigstem - Rapid prototyping with Twig templates
CD into the project directory and run composer install
composer install
Install node modules
npm install
The final directory structure:
├── public
│ ├── .htaccess
│ ├── index.php
├── src
│ ├── data
│ ├── views
├── vendor
├─- composer.json
Twigstem will attempt to load a template matching the requested url.
/about => loads views/about.twig
/more/info => loads views/more/info.twig
Add new templates to the src/views directory.
Data can be associated with a page in any of these ways:
views/products.twig
views/products.json
views/products.twig
data/products.json
{# data src: index.json #}
You can optionally include an ID when specifying a data file. If an ID is provided, the data returned is include in the page context under this ID. For example
{# data src: products.json #}
{# data id:sizes src: sizelist.json #}
Twigstem will look for a class called TwigExtension. If found, this will be instantiated and added to twig as an extension.