Download the PHP package trq/gen without Composer
On this page you can find all versions of the php package trq/gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package gen
Short Description A very very simple static site generator using Twig
License MIT
Informations about the package gen
Gen
A very very simple static site generator using the Twig template engine.
I developed this very very simple static site generator specifically for generating the http://proemframework.org web site. It is indeed, very very simple.
Installation
The best way to install Gen is via Composer. The following, will create a composer.json file, install all dependencies and bootstrap a skeleton app.
By default Gen expects to find the following structure within the source directory:
An Example
Results in:
Injecting Data
Data (variables, arrays, objects) can be injected into templates at certain levels.
Data is injected by simply creating a .php file that returns the data you want in an array.
Firstly, you can create a global.php file and drop it into the root of the source directory. This data will be available to all templates unless overwritten further down.
Secondly, you can create a local.php file within any sub directory. The data this file provides will be merged with the global.php file above (overwriting any duplicate keys).
Lastly, you can create a .php file with the same name as your .twig file. The data returned by this file will again be merged into the data provided above, and the results will be made available only within the .twig file of the same name.
Twig Extensions
To use a custom Twig extension simply create a class extending the Gen\Twig\ExtensionBase within the Gen namespace and drop it's file into the extensions directory and extend the Gen\Twig\ExtensionBase class.
By extending the Gen\Twig\ExtensionBase your extension will automatically gain access to the current directory being processed, the current file being processed, all options that have been passed into Gen and all data that is currently available.
For information about creating Twig Extensions see http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
Configuration
All directories and files used by Gen can be easily configured by placing a gen.conf.php file into the root of the source directory and having it return an array of the options you wish to overwrite. By default, this array looks like:
Where $src is either passed into Gen or uses the current working directory as default and $dest is either passed into Gen or uses $src/build by default.
Using the command line helper
Gen comes with a very simple command line utility used to process your site. It has available the following options:
All of these options are optional. If no source directory is provided the current working directory will be used.