A complete and fully-functional implementation of the Jade template language for PHP

Related tags

Templating tale-jade

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.

Since the official implementation of Jade has been renamed to PugJS, Tale Jade has been renamed to Tale Pug!

You can still use this implementation freely, but this repository won't receive updates anymore.

You can find all documentation over at the Pug Repository.

Visit the Tale Pug Repository

  • Alternative name

    Alternative name

    We need a new name.

    4 Characters maximum.

    Can I have some input on this? Maybe even some name suggestions?

    Any idea or feedback is welcome :)

    Current Name-Suggestions by probability that I'll take them:

    • Chi (.chi, .jade, .jd)
    • Shi (.shi, .jade, .jd)
    • Inu (.inu, .jade, .jd)

    Update (15.12.2016):

    Tale Jade will be Phug in the future, a collaboration project of currently existing Jade/Pug implementations

    help wanted refactoring needed 
    opened by TorbenKoehn 32
  • Allow arbitrary spacing/indentation in php code block and text block (multiline)

    Allow arbitrary spacing/indentation in php code block and text block (multiline)

    This is kind of annoying bug to my experience. Let's take an example:

         * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
         * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
    doctype html

    This snippet gives me Jade parse error, it says like this: Failed to parse jade: Mixed indentation style encountered. Dont mix tabs and spaces. Stick to one of both. (Line: 3, Offset: 2)

    opened by elquimista 31
  • Buffered code blocks

    Buffered code blocks

    It would be incredible useful to have support for buffered code blocks, because PHP code is so messy. :)

    I have to resort to this hack when dealing with a buffered object:

        $columns = ['id','tracker_id', 'project_id', 'subject',
        'description:ntext', 'issue_category_id', 'user_id', ['class' => 'yii\\grid\\ActionColumn',
         'contentOptions' => ['nowrap'=>'nowrap'] ] ]
      !=GridView::widget(['dataProvider'=> $dataProvider,'filterModel'=> $searchModel,'columns'=> $columns])
    opened by jacmoe 18
  • Another interpolation issue

    Another interpolation issue

    Here's an example:

    .col.s6.right-align #[strong Sign In] / !{$view->Html->link('Sign Up', ['action' => 'add'])}

    This should be interpreted as:

    <div class="col s6 right-align">
        Sign In 
      </strong> / <?=$view->Html->link('Sign Up', ['action' => 'add'])?>

    But it's misinterpreted like this:

    <div class="col s6 right-align">
        Sign In] / <?=$view->Html->link('Sign Up', ['action' => 'add'

    I confirmed it on talejade sandbox.

    I think this is caused by wrong lookup of matching brackets during interpolation processing.

    opened by elquimista 14
  • Need help creating documentation!

    Need help creating documentation!

    I really need help creating more documentation resources.

    If anyone is willing to help, I'd provide everything needed including an information channel that knows all deep secrets of Jade (me).

    What I need exactly is:

    1. PHP Doc Blocks in the 1.5 and 1.6 branches (many doc blocks...)
    2. A real (possibly Jade&Bootstrap powered) Open Source website that will be hosted at http://jade.talesoft.io containing
      • The sandbox (Might also be re-written)
      • Installation and usage guides
      • A list of all common features of Tale Jade
      • A list of advanced techniques with Tale Jade (There are quite a few, I just forget them when I try to write them down)
      • A developer's guide for extending Tale Jade (Necessary after 1.5)
    3. Maybe a new README that is cleaner to read and references the website correctly
    4. Maybe, just maybe, a really cool and actually working phpdoc-template.
    5. A logo! (Maybe with a neat Jade-stone or something like that)

    Any help is appreciated

    help wanted 
    opened by TorbenKoehn 14
  • Inconsistent unbuffered code

    Inconsistent unbuffered code

    First of all: thanks for making this library!

    I am fully aware that it is wet paint, but I've decided to take the plunge - after examining the alternatives - and integrate this with Yii2.

    It really threw me for a loop, when I discovered - after many cryptic error messages - that I should not prepend conditional php code with the dash:

    if $something

    If would be better, and more consistent, to let that be unbuffered code:

    - if $something


    -if $something

    If it threw me, it would probably trip someone else up as well. :)

    opened by jacmoe 14
  • Nested mixin call before definition error

    Nested mixin call before definition error

    Calling in mixin other mixin defined later in same file with params cause Compiler exception

    2 0.0289 334680 Tale\Jade\Renderer->render( ) 3 0.0342 344896 Tale\Jade\Renderer\Adapter\File->render( ) .../Renderer.php:340 4 0.0361 345432 Tale\Jade\Renderer->compileFile( ) .../File.php:173 5 0.0361 345480 Tale\Jade\Compiler->compileFile( ) .../Renderer.php:316 6 0.0389 347288 Tale\Jade\Compiler->compile( ) .../Compiler.php:542 7 0.6745 1275980 Tale\Jade\Compiler->handleMixins( ) .../Compiler.php:476 8 0.7064 1334288 Tale\Jade\Compiler->handleMixin( ) .../Compiler.php:1268 9 0.7065 1334432 Tale\Jade\Compiler->compileChildren( ) .../Compiler.php:1297 10 0.7065 1334916 Tale\Jade\Compiler->compileNode( ) .../Compiler.php:1892 11 0.7065 1335264 call_user_func:{/adv/vhosts/vsk.a.adv.ru/personal/vendor/talesoft/tale-jade/Compiler.php:925} ( ) .../Compiler.php:925 12 0.7065 1335280 Tale\Jade\Compiler->compileMixinCall( ) .../Compiler.php:925

    Following example cause this error: `mixin a(a) a= a +b(a) mixin b(b) b=b


    opened by ArSharlahy 13
  • Official Jade has different whitespace handling

    Official Jade has different whitespace handling

    Considering this:

    span foo
    | bar

    The offical Jade engine compiles this to:


    While Tale Jade gives me this (regardless of the pretty output setting):


    So Tale Jade makes it rather hard to have the two parts joined without a space. One of the reasons I love Jade is that it always flattens whitespace, and you have to explicitly add spaces if you want them.

    enhancement pug-inconsistency 
    opened by lensco 12
  • Another issue with latest version (v1.3.4)

    Another issue with latest version (v1.3.4)

    This issue is related to include statement.


    h2 Hello


    include mixin.jade

    After compilation, it should generate only 1.html with the following contents:


    But the result is it generates 1.html as well as mixin.html. And the contents are not good. mixin.html



    h2 Hello

    This is certainly a bug right?

    opened by elquimista 9
  • Loading same file for simple content loading and js content loading

    Loading same file for simple content loading and js content loading

    Is there a way that I can create a single file and use for both purpose. One I am loading the contents setting some variable and if the content will send from js it will replace those variables?

    opened by aavrug 9
  • check template's filemtime() before taking compiled from cache

    check template's filemtime() before taking compiled from cache

    When ttl option is set, tale-jade does not care whether source template was changed or not. It just sends cached file to render.

    It would be desirable to have an option to check source tempate filemtime() previously. And if source template was changed, regenerate the cache for it.

    E. g. 'auto_update' => true|false.

    opened by cronfy 10
  • Automatic isset-checks behave differently in different cases

    Automatic isset-checks behave differently in different cases

    Consider this code:

    p #{$var}


      <?=htmlentities(isset($var) ? $var : '', \ENT_QUOTES, 'UTF-8')?>
      <?=htmlentities($var, \ENT_QUOTES, 'UTF-8')?>

    First occurence was checked by isset, and second was not.

    1. Is it possible to configure isset checks to behave the same way through all the code?
    2. It is possible to disable isset checks completely?
    opened by cronfy 6
  • HTML minification can break inline scripts

    HTML minification can break inline scripts

    Using this jade syntax:

      // JS code here...

    Without pretty when rendering collapses all the line breaks in the script code without intelligent consideration for semicolons. This breaks most inline scripts if you don't use semicolons, which is valid JS and an enforced coding style in many teams (see JavaScript Standard Style).

    Pug has no issues and intelligently minifies the JS inside inline scripts.

    enhancement pug-inconsistency 
    opened by jaydenseric 1
  • Boolean attribute issues

    Boolean attribute issues

    It seems Tale Jade does not render boolean attributes smart like Pug does.



    <button disabled="true"></button>
    <button disabled="false"></button>






    - $disabled = true;
    - $disabled = false;

    Both render:

    <button disabled="1"></button>

    Ideally, specifying true or false would render:

    <button disabled></button>

    In my component mixins I am resorting to the rather verbose:

    - $disabled = false;
    button(disabled=($disabled ? 'disabled' : false))

    To render:

    <button disabled="disabled"></button>

    According to the HTML5 spec, boolean attributes should only ever be valueless or contain the exact attribute to indicate true, or contain an empty string or be omitted to indicate false.

    bug pug-inconsistency 
    opened by jaydenseric 3
  • Nested mixin block content loses scope

    Nested mixin block content loses scope

    In Pug, this:

    mixin test
    - $text = 'Test text';


    <p>Test text</p>
    <p>Test text</p>

    In Tale Jade, the very same renders:

      Test text</p>

    This is a big blocker to porting my Pug templates over, not really sure how to handle it.

    opened by jaydenseric 15
  • Attribute Shortcuts

    Attribute Shortcuts

    Found it here

    Though, I don't like the system they use, since it reduces the portability of templates (You'd always need the same config file everywhere) and it can confuse people when someone uses @ for role and some @ for data-whatever.

    My approach is something similar to Aliases.

    shortcut @(role data-role)
    [email protected]

    resulting in

    <nav class="main-nav" role="navigation" data-role="navigation"></nav>

    These shortcuts could be defined at the top of your base-layout or in another file that get's included (similar to mixins)

    opened by TorbenKoehn 0
  • Convert array to data-attributes

    Convert array to data-attributes

    Found it here

    I could imagine it like this:

    div&data(['some-key' => 'some value', 'int' => 14])

    resulting in

    <div data-some-key="some value" data-int="14"></div>
    opened by TorbenKoehn 0
  • Symfony readiness

    Symfony readiness

    Tale Jade works with Symfony, but not too well right now.

    I've created an implementation (will put it online soon), a JadeBundle, for Symfony2/3.

    Some of the problems have already been taken care of in 1.5, but there might be a possibility for a 1.4.3 bringing in Symfony compatibility until 1.5 is finally there

    The following problems arised and need to be taken care of;

    • No : in paths allowed. Right now // acts as a workaround, which is ugly
    • A real Filename Resolver is needed that can be swapped out with a Symfony-specific implementation using Symfony's TemplateNameParser and TemplateLoader. Right now resolving consists of Compiler->resolvePath only.
    • The rendererer adapters shouldn't ever modify the original path that is passed to the resolver. Right now the File adapter strips the .jade/.jd extension from the path.
    • Renderer adapters should filter cache keys better (Any kind of invalid path character should be replaced with e.g. -. Another possibilty would be something like basename($path).'-'.md5($path) since the only reason to even keep the file names is to look up some PHTML code that bugs, the base name would be sufficient.
    • No real extensions possible (e.g. Twig's asset()-function). Right now the solution is passing it as a variable (link(rel=$asset('style.css'))). This isn't even too shabby and it's valid PHP. I honestly don't want to bring in any new fancy syntax and we can't put it into a new element or merge it with mixins, because we also want to use them in attributes and maybe even PHP code.
    • Configuration overhaul might be needed before 1.5, which would make it 1.5. I don't know yet. I'm converting the keys right now which is just a useless performance loss. Would be stubborn from my side not converting the camelCase keys to under_scores.

    Well...the other parts are really cool. It can replace Twig completely.

    import JadeBootstrapBundle::mixins.html.jade will be pretty awesome as well.

    Stay tuned.

    opened by TorbenKoehn 7
  • Support for dynamic includes

    Support for dynamic includes

    Hi, Torben! I create a frontend tool for building OnePage websites without using Gulp, PHP only. And I need dynamic includes for sections, which are located in a specific folder, named app/sections. The number and names of include files is unknown, but they will be called in accordance with the mask: (section-number)(section-name).jade. Whether such inclusion in the current version of your library? I would be grateful for a code example.

    opened by zorca 5
  • Support for multiline markup

    Support for multiline markup

    class="paragraph">But you can also use normal HTML!</p>

    is transformed into

      <?=htmlentities("paragraph">But you can also use normal HTML!</p>, \ENT_QUOTES, 'UTF-8')?>
    opened by hason 1
  • 1.4.5(Aug 23, 2016)

    This patch contains a lot of bug-fixes. Please update as soon as possible.

    • Updated Symfony mb polyfill to 1.2.0
    • Addressed #100, still not satisfied with the solution (but it works well, for ternary operators at least)
    • Addressed #109, the ignored variables are now a constant Tale\Jade\Compiler\IGNORED_SCOPE_VARIABLES. Define it prior to loading Tale Jade to specify own ignored variables (separated by :)
    • Addressed #115, mixins can now be called in a circular way and get resolved correctly
    • Addressed #113, classes can now start with a dash
    • Addressed #112, block expansion now handles following classes correctly
    • Addressed #108 and improved error handling, including a re-write of most exception messages with more details
    • Add is_object check to build_value function of the Compiler namespace to remove __toString-errors
    Source code(tar.gz)
    Source code(zip)
  • 1.4.4(Jun 4, 2016)

    • Mixins now have proper scoping without $__args (Means you can also include generated templates with your own variable scope easily)
    • Some bugfixes
    Source code(tar.gz)
    Source code(zip)
  • 1.4.2(Apr 7, 2016)

    • Cleaned up dev-dependencies
    • Now using PSR2 fully over the whole project.
    • tale-config is now used in version 0.2 (PSR-2)
    • Fixed a bug with name-only attributes separated with spaces (#66)
    • HTML5-mode now doesn't self-close attributes at all (#66)
    • The lexer now prints a little piece of jade code to find errors faster
    • Fixed a bug regarding IE conditional comments and interpolation (#75)
    • Added composer.lock to prevent stuff like the reason for 1.4.1.
    • Make sure that compiler doesn't echo XML doctypes in tests when running in HHVM.
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Feb 3, 2016)

    Added the ?-instruction ("unchecked"-operator)

    Disables automatic isset()-checks on variables for certain cases (e.g. objects with __get, but without __isset)


    p?= $someVar a(href?=$someVar)

    It can be combined with the !-escaping-instruction

    p?!= $someVar a(href?!=$someVar)

    Added !-instruction on texts to enable escaping

    Sometimes you want to escape text, e.g. when you want to display the HTML, not let it render For that all text-elements can now be prefixed with ! to enable escaping.

    Escaped texts will still support interpolation.


    h1 My example code
    pre: code!.
             $someVar = 123;
             echo $someVar;

    p! This HTML <em>here</em> will be escaped

        !| This text will also be escaped
    • Improved variable detection. Variables like $someVar["some, weird$9 key"] will also be automatically enclosed in the isset-check now
    • Fixed a bug with a trailing semicolon in variadics (#61)
    • Updated README-file to reflect latest config changes
    Source code(tar.gz)
    Source code(zip)
  • 1.3.7(Feb 1, 2016)

    • Improved interpolation. Interpolation can now be nested and many limits have been removed. Check the tests to see what's possible
    • composer.json has been cleaned up
    • tale-config is now used as a modular configuration approach through tale-* components
    Source code(tar.gz)
    Source code(zip)
  • 1.3.6(Jan 16, 2016)

    • Lexer makes less noise on spaces
    • Added ConfigurableTrait docs
    • Fixed a problem with attribute escaping (#48)
    • Fixed a tab conversion bug in parser configuration (#44)
    • Disabled xdebug in travis
    • Optimized travis.yml
    Source code(tar.gz)
    Source code(zip)
  • 1.3.5(Jan 16, 2016)

    • Fixed a bug where the extensions in the compiler were checked without the .-prefix in handleImport (#48)
    • Configuration-style now follows Tale\Jade\Util\ConfigurableTrait globally
    • Added some configuration utility methods to all objects
    • lifeTime, cachePath, indentStyle, indentWidth, extensions, mode, doctypes, filters and filterMap can now directly be set in the Renderer (No compilerOptions needed)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.4(Jan 15, 2016)

    • Cleaned up tests
    • XML encoding will now be echoe'd by default in HHVM. An option echoXmlDoctype has been added to enable it manually
    • Compiler now handles doctypes correctly (Fixed #2)
    • Multiple extensions allowed via compiler's "extensions" options ("extension" has been removed) (Fixed #3)
    • .jd can now be used as an extension by default (.jade still works)
    • Some improved error handling
    • Doctype tests
    • Reworked the text-block lexing (#42)
    • Changed attribute parsing so that expressions like function calls are possible (Fixed #41)
    • Compiler will now always return Compiler-Exeptions, but will include the compiled file path (if any) in the message (Fixed #43)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.2(Jan 5, 2016)

  • 1.3.1(Jan 5, 2016)

    Attributes can now be separated with spaces

    a(href='google.de' target='_blank')

    It's also possible to mix separators

    a(href='google.de' target='_blank', title='Some link title')
    Source code(tar.gz)
    Source code(zip)
  • 1.2.2(Nov 11, 2015)

    Tale Jade now has inbuilt support for common pre-processors

    You can either use them by using the filter-construct

        p {
            &.red { color: red; }
            &.blue { color: blue; }

    or by using import and import-filters or filter-mapping

    //Will automatically set the filter to "less"
    include my-less-file.less
    //will include my-less-file.less automatically
    include:less my-less-file

    The following pre-processors are now supported:


    Required Composer Package



    :markdown or :md




    Required Composer Package



    :coffeescript or :coffee




    Required Composer Package







    Required Composer Package



    :stylus or :styl




    Required Composer Package





    .sass or .scss

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Nov 9, 2015)

    • Improved PHP-expression parsing
    $columns(subArray=['some-sub-array' => 'some-value'])

    will now correctly parse to

    <?php $columns = ['subArray' => ['some-sub-array' => 'some-value']]; ?>
    • null, false and true scalars are now correctly handled and converted to the PHP boolean/null equivalent
    • Added the possibility to single-line-comment inside attribute-blocks
    (It actually compiles to something more useful, check the PHTML output, but this is what it essentially is for)
        //data-omitted='this is omitted for now',
    Source code(tar.gz)
    Source code(zip)
  • 1.2(Nov 6, 2015)

    For-Loops are now supported

    for $i = 0; $i < 100; $i++
        p We are at #{$i}, counting to 100!

    Variables can now be directly assigned

    $i = 100
    p Here is my new i: #{$i}
    $array(key1=value1, key2=value2, key3=value3)
    $inner = ['a', 'b', 'c']
    $outer(inner=$inner, 'd', 'e', 'f)
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Nov 5, 2015)

    • dash-code is now a code-node and token, not expression anymore. Expressions stay as they are
    • Removed the possibility to have expressions on multiple lines
    • Added the possibility to do this:
    - for ($i = 0; $i < 100; $i++):
        p #{$i}
    - endfor;
    Source code(tar.gz)
    Source code(zip)
  • 1.1(Oct 10, 2015)

  • 1.0.3(Oct 9, 2015)

  • 1.0(Oct 6, 2015)

    The first release of the Tale Jade project.

    Many things have been tested correctly, some things may still provide bugs.

    We'll see how it works out.

    Source code(tar.gz)
    Source code(zip)
Awesome software made in Berlin
Twig, the flexible, fast, and secure template language for PHP

Twig, the flexible, fast, and secure template language for PHP Twig is a template language for PHP, released under the new BSD license (code and docum

Twig 7.3k Nov 24, 2021
Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

Aura for PHP 81 Nov 16, 2021
Multi target HAML (HAML for PHP, Twig, )

Multi target HAML MtHaml is a PHP implementation of the HAML language which can target multiple languages. Currently supported targets are PHP and Twi

Arnaud Le Blanc 362 Aug 5, 2021
☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites.

Latte: amazing template engine for PHP Introduction Latte is a template engine for PHP which eases your work and ensures the output is protected again

Nette Foundation 731 Nov 27, 2021
The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS! Some information before we start This repo is only code related, to a

Ilian 5 Nov 3, 2021
The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS! Some information before we start This repo is only code related, to a

Ilian 5 Nov 3, 2021
⚡️ Simple and fastly template engine for PHP

EasyTpl ⚡️ Simple and fastly template engine for PHP Features It's simple, lightweight and fastly. No learning costs, syntax like PHP template It is s

PHPPkg 9 Nov 26, 2021
PHP template engine for native PHP templates

FOIL PHP template engine, for PHP templates. Foil brings all the flexibility and power of modern template engines to native PHP templates. Write simpl

Foil PHP 163 Nov 20, 2021
A SilverStripe Module with template methods to quickly make use of FocusPoint, LazySizes, and Object-fit

LazyFocusFit A SilverStripe module with template methods to quickly make use of FocusPoint, LazySizes and object-fit. Requirements PHP FocusPoint JS/C

Evans Hunt 8 Oct 12, 2021
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.

Smarty 3 template engine smarty.net Documentation For documentation see www.smarty.net/docs/en/ Requirements Smarty can be run with PHP 5.2 to PHP 7.4

Smarty PHP Template Engine 1.9k Nov 23, 2021
Native PHP template system

Plates Plates is a native PHP template system that's fast, easy to use and easy to extend. It's inspired by the excellent Twig template engine and str

The League of Extraordinary Packages 1.3k Nov 19, 2021
View template engine of PHP extracted from Laravel

Blade 【简体中文】 This is a view templating engine which is extracted from Laravel. It's independent without relying on Laravel's Container or any others.

刘小乐 145 Aug 13, 2021
A ready-to-use Model View Controller template in PHP

PHP-MVC-Template A ready-to-use Model View Controller template in PHP Use this repo as a template! (Or clone it) Start to configure your MVC file Afte

Loule | Louis 6 Nov 19, 2021
Provides a GitHub repository template for a PHP package, using GitHub actions.

php-package-template Installation ?? This is a great place for showing how to install the package, see below: Run $ composer require ergebnis/php-pack

null 260 Nov 24, 2021
A lightweight template parser used by PyroCMS.

Lex Lex is a lightweight template parser. Lex is released under the MIT License and is Copyrighted 2011 - 2014 PyroCMS Team. Change Log 2.3.2 Convert

PyroCMS 103 Nov 15, 2021
Laravel package template

REPLACE Simple and flexible package template. Usage Replace all occurances of REPLACE (case sensitive) with the name of the package namespace. E.g. th

ARCHTECH 47 Nov 24, 2021
The Templating component provides all the tools needed to build any kind of template system.

Templating Component The Templating component provides all the tools needed to build any kind of template system. It provides an infrastructure to loa

Symfony 982 Nov 23, 2021
Document templates Laravel package is intended for creating/managing user editable document template

Document Templates Introduction Document templates Laravel package is intended for creating/managing user editable document templates, with ability to

42coders 99 Nov 14, 2021
Astroid Framework - Powerful Joomla Template Framework

Powerful framework for designers and developers to create responsive, fast & robust Joomla based websites and templates.

TemPlaza 9 Nov 23, 2021