Tale Jade for PHP

GitHub release Travis Packagist HHVM License Gitter

Finally a fully-functional, complete and clean port of the Jade language to PHP

— Abraham Lincoln

The Tale Jade Template Engine brings the popular and powerful Templating-Language Jade for Node.js to PHP!

Tale Jade is the first complete and most powerful Jade implementation in PHP.


Currently looking for contributors. If you're interested and require any resources or info about the engine, drop an E-Mail on torben@talesoft.codes. Thank you.

What is Tale Jade

It's a template engine that doesn't focus on abstracting PHP, but focuses on abstracting HTML.

Why another template engine?, you might ask.

Template engines like Twig or Blade are pretty cool and functional, but they all lack one common thing: HTML abstraction.

You still have to write all those tags, brackets and quotes, you have to close tags and make sure that you keep your structure consistent. It's verbose and it takes large sizes on bigger sites pretty quick.

Similar to HAML, but less verbose, Tale Jade takes both approaches, it abstracts PHP as well as HTML. It works based on indentation and simple CSS-selectors to create your HTML as clean and quick as possible. It also involves a lot of dynamic features, you won't need any line of HTML or PHP to write your templates anymore. You only need Tale Jade.

Furthermore, Tale Jade can handle different output formats through its syntax. That way you can use Tale Jade for HTML5, XHTML or XML templates just by changing the doctype and it will automatically make sure to always render valid markup.

Below you have some examples, feature-links, links to documentation and a sandbox where you can play in. Check them out!

Don't fear the syntax. Let me stress this out because I've read a lot about people being scared of Jade syntax. It is basically indented CSS-selectors and a few characters to control what you output. Once you wrote a few templates with it, I assure you, you'll love it!

Getting Started

Install with Composer

Download Composer

The composer package for Tale Jade is called talesoft/tale-jade

If you want to get started right now, hook up composer and run

$ composer require "talesoft/tale-jade:*"

or add it to your composer.json by yourself

    "require": {
        "talesoft/tale-jade": "^1.4.5"

Note: If you're not using composer, make sure to also include the Compiler/functions.php file

Rendering a Jade Template

Include the vendor/autoload.php file of composer in your PHP script and get started with Tale Jade!

use Tale\Jade;

//Include the vendor/autoload.php if you're using composer!

$renderer = new Jade\Renderer();

echo $renderer->render('your-jade-file');

This way, the renderer will search for your-jade-file.jade in your get_include_path()-paths. Notice that the path passed to render should be relative. You can give it absolute paths, but it will make caching harder.

We show you how to add alternative search paths further in the Basic configuration section below.

When the Jade-file gets rendered, a ./cache/views-directory is created automatically and the compiled PHTML will be stored in that directory.

To change this directory, use the cache_path-option

$renderer = new Jade\Renderer([
    'cache_path' => '/your/absolute/cache/path'

The Jade-file will now be rendered to that directory on each call.

To enable a cache that won't render the files on each call, use the ttl option of the file-adapter

$renderer = new Jade\Renderer([
    'ttl' => 3600 //Will cache the file for 3600 seconds (one hour)

Basic configuration

To enable formatting of the PHTML-output, use the pretty-option

$renderer = new Jade\Renderer([
    'pretty' => true

If you don't want to use the get_include_path()-paths (which could actually harbor a security risk in some cases), pass your own search paths to the Renderer. Rendered and included Jade-files will be searched in those paths and not in the get_include_path()-paths anymore.

//Either with
$renderer = new Jade\Renderer([
    'paths' => [__DIR__.'/views']

//or with

As soon as you pass any path, the loading from the get_include_path()-paths will be disabled and you always load from your passed directory/ies.

To pass variables to your Jade-file, use the second argument of the render-method

echo $renderer->render('index', [
    'title' => 'Jade is awesome!',
    'content' => 'Oh yeah, it is.'

These can be used inside Jade as normal variables

h1= $title


Supported features

Tale Jade supports every single feature the original Jade implementation supports! This always has been and will always be the main target.

But why stop there? PHP has it's own features that are surely different from JavaScript's. By utilizing those features it aims to bring in more, compatible features into the language to make the fastest template development ever possible!

You can try each feature and see a bunch of examples on my sandbox site

Supported official Node.js Jade Features

Supported Tale Jade Features

Other cool features

There's more to come...

Tale Jade is actively used and developed in many projects and is improved constantly.

It doesn't stick to the Jade-convention, but it will always provide compatibility to Node.js Jade to help reducing confusion.

Planned features:

Documentation Resources

Tale Jade Live Compiler A compiler for you to play with in your browser as well as a whole bunch of examples to give you a grasp of what Tale Jade is capable of.

The Tale Jade API Docs The documentation of the Tale Jade source code. Generated with phpDocumentor, but is's fairly enlightening.

Official Node.js Jade Documentation The real thing. This is where everything that I do here originates from. The syntax is the same, only the code-expressions are different.

Tale Jade Bootstrap A quick-start project to get you up and running. Fork it, download it, play with it. Don't forget to run composer install before launching (Download Composer)

Development Test Files The example files I tested the engine with.

Tale Jade Unit Tests The Unit Tests I'm using to ensure stability. There will be new tests added constantly and most features are covered here. It's PHP code, though.

Tale Jade for your favorite framework

You're using a framework with a template engine already, but you really want to try out Jade? Search no further.

Thanks to the Tale Jade Community there are some modules for existing frameworks that allow you to use Tale Jade easily!

Laravel Framework

Symfony 2/3

Yii2 Framework


CakePHP 3


Symphony XSLT CMS

Your framework is missing? Send me an e-mail and we'll get a bridge up and running as soon as possible!

A great thanks to the contributors of these modules!

Get in touch and support my work

If you find a bug or miss a function, please use the Issues on this page to tell me about it. I will gladly hear you out :)

If this library helped you, eased up your work and you simply can't live without it, think about supporting my work and spend me a coffee. Thank you!

If you'd like to contribute, fork, send pull requests and I'll take a deep look at what you've been working at! Tale Jade is completely Open Source! You can do anything you like with the code as long as you stick to the MIT-license I've appended. Just keep my name somewhere around!

You can also contact me via E-Mail torben@talesoft.codes

Thank you for using Tale Jade. Let us spread the Jade-language together!