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

Last update: May 4, 2021

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


GitHub

https://github.com/Talesoft/tale-jade
Comments
  • 1. 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

    Reviewed by TorbenKoehn at 2016-04-08 14:23
  • 2. 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)

    Reviewed by elquimista at 2016-01-15 14:10
  • 3. 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])
    
    Reviewed by jacmoe at 2015-11-06 11:44
  • 4. 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

    Reviewed by TorbenKoehn at 2016-04-08 11:17
  • 5. 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">
    
      <strong>
        Sign In 
      </strong> / <?=$view->Html->link('Sign Up', ['action' => 'add'])?>
    </div>
    

    But it's misinterpreted like this:

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

    I confirmed it on talejade sandbox.

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

    Reviewed by elquimista at 2016-02-01 08:18
  • 6. 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
      ..
    

    or

    -if $something
      ..
    

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

    Reviewed by jacmoe at 2015-11-04 22:53
  • 7. 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

    +a('a')`

    Reviewed by ArSharlahy at 2016-07-07 09:03
  • 8. Official Jade has different whitespace handling

    Considering this:

    span foo
    | bar
    

    The offical Jade engine compiles this to:

    <span>foo</span>bar
    

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

    <span>
      foo
    </span>
    bar
    

    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.

    Reviewed by lensco at 2016-05-12 14:21
  • 9. 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?

    Reviewed by aavrug at 2016-06-15 06:15
  • 10. Another issue with latest version (v1.3.4)

    This issue is related to include statement.

    mixin.jade

    h2 Hello
    

    1.jade

    include mixin.jade
    

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

    <h2>Hello</h2>
    

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

    <h2>Hello</h2>
    

    1.html

    h2 Hello
    

    This is certainly a bug right?

    Reviewed by elquimista at 2016-01-16 14:26
  • 11. Code blocks

    I get this error when I try to use block buffered code:

    Failed to parse jade: You should indent in by one level only

    This kind of code can reproduce the error:

            -
              $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
                             'url' => ['/site/logout'],'linkOptions' =>['data-method' => 'post']]
    
    Reviewed by jacmoe at 2015-11-05 11:11
  • 12. 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.

    Reviewed by cronfy at 2016-12-23 08:00
  • 13. Automatic isset-checks behave differently in different cases

    Consider this code:

    p #{$var}
        $var
    

    Produces:

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

    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?
    Reviewed by cronfy at 2016-12-16 13:08
  • 14. HTML minification can break inline scripts

    Using this jade syntax:

    script.
      // 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.

    Reviewed by jaydenseric at 2016-11-10 00:50
  • 15. Boolean attribute issues

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

    button(disabled=true)
    button(disabled=false)
    

    Renders:

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

    While:

    button(disabled=#{true})
    button(disabled=#{false})
    

    Crashes.

    button(disabled=(true))
    button(disabled=(false))
    

    And:

    - $disabled = true;
    button(disabled=$disabled)
    - $disabled = false;
    button(disabled=$disabled)
    

    Both render:

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

    Ideally, specifying true or false would render:

    <button disabled></button>
    <button></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>
    <button></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.

    Reviewed by jaydenseric at 2016-09-05 08:24
  • 16. Nested mixin block content loses scope

    In Pug, this:

    mixin test
      block
    
    - $text = 'Test text';
    
    p=$text
    +test
      p=$text
    

    Renders:

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

    In Tale Jade, the very same renders:

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

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

    Reviewed by jaydenseric at 2016-05-20 12:53
  • 17. 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)

    Reviewed by TorbenKoehn at 2016-04-08 11:08
Related tags
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages

PHPTAL - Template Attribute Language for PHP Requirements If you want to use the builtin internationalisation system (I18N), the php-gettext extension

Apr 14, 2022
Twig, the flexible, fast, and secure template language for PHP
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

Jun 28, 2022
Prosebot is a template-based natural language generation application

Prosebot is a template-based natural language generation application. Throughout the last years, ZOS has been developing Prosebot, alongside their collaboration with FEUP, as part of the zerozero.pt project.

Jun 14, 2022
A template abstraction prototype for PHP template engines

Schranz Templating A template abstraction prototype for PHP template engines. This project should help to find a way for a general Template Render Int

Jun 25, 2022
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

Apr 22, 2022
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

Jun 3, 2022
A PHP project template with PHP 8.1, Laminas Framework and Doctrine

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

Mar 8, 2022
☕ 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

Jun 29, 2022
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!

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

May 20, 2022
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!

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

May 20, 2022
⚡️ 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

May 29, 2022
Foil brings all the flexibility and power of modern template engines to native PHP templates

Foil brings all the flexibility and power of modern template engines to native PHP templates. Write simple, clean and concise templates with nothing more than PHP.

May 10, 2022
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

May 10, 2022
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

Jun 17, 2022
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

Jun 25, 2022
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

Jun 24, 2022
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.

Jun 6, 2022
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

Jun 13, 2022
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

Jun 29, 2022