Converts templates with Jade-like syntax to PHP or Latte (Nette).
PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
composer.json
makefile
nette.md
readme.md

readme.md

Microjade

Converts templates with jade-like syntax to PHP or Latte.

Usage

$template = (new Microjade)->compile(file_get_contents('example.jade'));
file_put_contents('example.php', $template);
require('example.php');

For usage in Nette Framework see nette.md.

Supported syntax

<html>           - untouched
p(id="t1") Text  - html tag
link(abc)/       - self-closing tag
.class#id        - implicit div
| text           - unformated line
- code           - php code
= $var           - escaped variable
!= $var          - unescaped variable
-# comment       - single-line comment
// comment       - html block comment
script.          - unformated block
if, while, for.. - php blocks
block name       - print $name or saves block to $name

Inline macros

These macros can be used anywhere in template except in unformated blocks (like script.). Inline macros are left untouched for Latte output.

{$var}                   - prints escaped variable
{!$var}                  - prints unescaped variable
{-any_php_code()}        - alias for <?php ... ?>
{=any_php_code()}        - prints escaped result
{!any_php_code()}        - prints unescaped result
{block name} {/block}    - prints $name or saves block to $name
{if $x} {elseif $y} {else} {/if}
{while $x} {/while}
{foreach $x as $y} {/foreach}
{for $i=1; $i<=10; $i++} {/for}

Todo

  • switch, case and default blocks