Simple PHP CLI generator of static web sites.
- Texy! support
- Latte templates support
$ cd examples/basic
$ php -f ../../webgen.php -- --run
$ cd output
$ ls
articles index.html
Note: Webgen ignores files with @
on start of filename.
Texy in Latte template
{block |texy}
This is **Texy** snippet.
{/block}
{texy}
This is "Texy":https://texy.info snippet too.
{/texy}
Get name of current generated file
{$webgen->currentFile} {* prints for example: 'articles/article-2.texy' *}
Get relative path from currentFile
to a file
{$webgen->createRelativeLink('articles/article-1.html')}
{* prints:
'article-1.html' for currentFile = 'articles/article-2.texy'
'articles/article-1.html' for currentFile = 'index.texy'
*}
Shortcuts (output for currentFile = 'articles/article-2.texy'
)
{link articles/article-1.html} {* prints article-1.html *}
<a n:href="articles/article-1.html">Article #1</a>
{* prints *}
<a href="article-1.html">Article #1</a>
<link rel="stylesheet" n:href="css/style.css" type="text/css">
{* prints *}
<link rel="stylesheet" href="../css/style.css" type="text/css">
<img n:src="images/photo.jpg">
{* prints *}
<img src="../images/photo.jpg">
<img n:image="images/photo.jpg">
{* prints (image file must exist) *}
<img src="../images/photo.jpg" width="1024" height="768">
Relative paths in Texy:
"Article #1":@articles/article-1.html
[* @images/photo.jpg *]
Highlight current page in menu (is link current?)
<div id="menu">
<a n:href="/" n:class="$webgen->isLinkCurrent('index.texy') ? current">Homepage</a>
<a n:href="about-us/" n:class="$webgen->isLinkCurrent('about-us/**') ? current">About us</a>
<a n:href="contact.html" n:class="$webgen->isLinkCurrent('contact.*') ? current">Contact</a>
</div>
In mask **
means everything, *
means everything except /
.
Variables in Texy document
{{$var}}
{{$var = value}}
{{$var: value}}
Configuration is stored in file named config.neon
. NEON is format very similar to YAML, see https://ne-on.org/.
Change name of source or output directory
input:
dir: <new-source-dir-name>
output:
dir: <new-output-dir-name>
Change name of layout template
input:
layout: @my-layout-name.latte
Copy files from source directory into output directory (CSS & JS files, images,...)
Boolean value (yes
/no
) or filemask(s):
input:
copy: yes
input:
copy:
- *.js
- *.css
Change default output file extension
output:
ext: php
File-specific change:
{webgen ext => php} ## in Latte template
{{webgen: ext: php}} ## in Texy file
Change output filename
## changes output file extension
{webgen ext => php}
## changes output basename of file
{webgen name => my-first-page}
## changes output filename (ignores 'ext' option)
{webgen filename => my-first-page.html}
See example pagination-repeated-generating.
Articles:
- https://www.janpecha.cz/blog/webgen-2-1/ (in Czech)
- https://www.janpecha.cz/blog/webgen/ (in Czech)
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/