PHPackages                             maht0rz/jade - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. maht0rz/jade

ActiveLibrary[Templating &amp; Views](/categories/templating)

maht0rz/jade
============

Jade of Maht0rz / pagon version had broken ? regex, so i edited it a bit!

1.0.0(13y ago)023911MITPHPPHP &gt;=5.3.0

Since Mar 6Pushed 11y ago1 watchersCompare

[ Source](https://github.com/maht0rz/jade.php)[ Packagist](https://packagist.org/packages/maht0rz/jade)[ RSS](/packages/maht0rz-jade/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

Jade - template compiler for PHP5.3
===================================

[](#jade---template-compiler-for-php53)

*Jade* is a high performance template compiler heavily influenced by [Haml](http://haml-lang.com)and implemented for PHP 5.3.

Features
--------

[](#features)

- high performance parser
- great readability
- contextual error reporting at compile &amp; run time
- html 5 mode (using the *!!! 5* doctype)
- combine dynamic and static tag classes
- no tag prefix
- clear &amp; beautiful HTML output
- filters
    - :php
    - :cdata
    - :css
    - :javascript
- you even can write &amp; add own filters throught API
- [TextMate Bundle](http://github.com/miksago/jade-tmbundle)
- [VIM Plugin](http://github.com/vim-scripts/jade.vim.git)

Public API
----------

[](#public-api)

```
$dumper = new PHPDumper();
$dumper->registerVisitor('tag', new AutotagsVisitor());
$dumper->registerFilter('javascript', new JavaScriptFilter());
$dumper->registerFilter('cdata', new CDATAFilter());
$dumper->registerFilter('php', new PHPFilter());
$dumper->registerFilter('style', new CSSFilter());

// Initialize parser & Jade
$parser = new Parser(new Lexer());
$jade   = new Jade($parser, $dumper);

// Parse a template (both string & file containers)
echo $jade->render($template);

```

Syntax
------

[](#syntax)

### Line Endings

[](#line-endings)

**CRLF** and **CR** are converted to **LF** before parsing.

### Indentation

[](#indentation)

Jade is indentation based, however currently only supports a *2 space* indent.

### Tags

[](#tags)

A tag is simply a leading word:

```
html

```

for example is converted to ``

tags can also have ids:

```
div#container

```

which would render ``

how about some classes?

```
div.user-details

```

renders ``

multiple classes? *and* an id? sure:

```
div#foo.bar.baz

```

renders ``

div div div sure is annoying, how about:

```
#foo
.bar

```

which is syntactic sugar for what we have already been doing, and outputs:

```

```

jade.php has a feature, called "autotags". It's just snippets for tags. Autotags will expand to basic tags with custom attributes. For example:

```
input:text

```

will expand to `` &amp; it's the same as `input( type="text" )`, but shorter. Another examples:

```
input:submit( value="Send" )

```

will become ``.

You can even add you own autotags with:

```
$parser->setAutotag('input:progress', 'input', array('type'=>'text', class=>'progress-bar'));

```

that will expands to ``.

It also supports new HTML5 tags (`input:email` =&gt; ``).

### Tag Text

[](#tag-text)

Simply place some content after the tag:

```
p wahoo!

```

renders `wahoo!`.

well cool, but how about large bodies of text:

```
p
  | foo bar baz
  | rawr rawr
  | super cool
  | go Jade go

```

renders `foo bar baz rawr.....`

Actually want `` for some reason? Use `{{}}` instead:

```
p {{$something}}

```

now we have ``

### Nesting

[](#nesting)

```
ul
  li one
  li two
  li three

```

### Attributes

[](#attributes)

Jade currently supports '(' and ')' as attribute delimiters.

```
a(href='/login', title='View login page') Login

```

Alternatively we may use the colon to separate pairs:

```
a(href: '/login', title: 'View login page') Login

```

Boolean attributes are also supported:

```
input(type="checkbox", checked)

```

Boolean attributes with code will only output the attribute when `true`:

```
input(type="checkbox", checked: someValue)

```

Note: Leading / trailing whitespace is *ignore* for attr pairs.

### Doctypes

[](#doctypes)

To add a doctype simply use `!!!` followed by an optional value:

```
!!!

```

Will output the *transitional* doctype, however:

```
!!! 5

```

Will output html 5's doctype. Below are the doctypes defined by default, which can easily be extended:

```
$doctypes = array(
       '5' => '',
       'xml' => '',
       'default' => '',
       'transitional' => '',
       'strict' => '',
       'frameset' => '',
       '1.1' => '',
       'basic' => '',
       'mobile' => ''
   );

```

Comments
--------

[](#comments)

### Jade Comments

[](#jade-comments)

Jade supports sharp comments (`//- COMMENT`). So jade block:

```
//- JADE
- $foo = "";
p
//- ##### COMMENTS ARE SUPPER! ######
  - switch ($foo)
    -case 2
      p.foo= $foo
//-    - case 'strong'
  //-      strong#name= $foo * 2
    -   case 5
      p some text

```

will be compiled into:

```

      some text

```

### HTML Comments

[](#html-comments)

Jade supports HTML comments (`// comment`). So block:

```
peanutbutterjelly
  // This is the peanutbutterjelly element
  | I like sandwiches!

```

will become:

```

  I like sandwiches!

```

As with multiline comments:

```
//
  p This doesn't render...
  div
    h1 Because it's commented out!

```

that compile to:

```

```

### IE Conditional Comments

[](#ie-conditional-comments)

Also, Jade supports IE conditional comments, so:

```
// [if IE]
  a( href = 'http://www.mozilla.com/en-US/firefox/' )
    h1 Get Firefox

```

will be parsed to:

```

```

Filters
-------

[](#filters)

Filters are prefixed with `:`, for example `:javascript` or `:cdata` and pass the following block of text to an arbitrary function for processing. View the *features*at the top of this document for available filters.

```
body
  :php
    | $data = 40;
    | $data /= 2;
    | echo $data;

```

Renders:

```

```

Code
----

[](#code)

### Buffered / Non-buffered output

[](#buffered--non-buffered-output)

Jade currently supports two classifications of executable code. The first is prefixed by `-`, and is not buffered:

```
- var $foo = 'bar';

```

This can be used for conditionals, or iteration:

```
- foreach ($items as $item):
  p= $item

```

Due to Jade's buffering techniques the following is valid as well:

```
- if ($foo):
  ul
    li yay
    li foo
    li worked
- else:
  p hey! didnt work

```

Second is echoed code, which is used to echo a return value, which is prefixed by `=`:

```
- $foo = 'bar'
= $foo
h1= $foo

```

Which outputs

```

```

### Code blocks

[](#code-blocks)

Also, Jade has Code Blocks, that supports basic PHP template syntax:

```
ul
  - while (true):
    li item

```

Will be rendered to:

```

    item

```

But don't forget about colons `:` after instructions start (`- if(true) :`).

There's bunch of default ones: `if`, `else`, `elseif`, `while`, `for`, `foreach`, `switch`, `case`.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4812d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e7941775d3bd932f21c0daf95eb47c6f92742a970a9bef768cf52a148eb859f6?d=identicon)[maht0rz](/maintainers/maht0rz)

---

Top Contributors

[![everzet](https://avatars.githubusercontent.com/u/30813?v=4)](https://github.com/everzet "everzet (70 commits)")[![hfcorriez](https://avatars.githubusercontent.com/u/119550?v=4)](https://github.com/hfcorriez "hfcorriez (1 commits)")[![maht0rz](https://avatars.githubusercontent.com/u/6826282?v=4)](https://github.com/maht0rz "maht0rz (1 commits)")

---

Tags

templatejadejade.php

### Embed Badge

![Health badge](/badges/maht0rz-jade/health.svg)

```
[![Health](https://phpackages.com/badges/maht0rz-jade/health.svg)](https://phpackages.com/packages/maht0rz-jade)
```

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.5k34.7M183](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

420137.3M46](/packages/rize-uri-template)[pug-php/pug

HAML-like template engine for PHP

393383.2k52](/packages/pug-php-pug)[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k12](/packages/phug-phug)[talesoft/tale-jade

A clean, lightweight and easy-to-use templating engine for PHP based on Jade/Pug

8919.3k5](/packages/talesoft-tale-jade)[talesoft/tale-pug

A clean, lightweight and easy-to-use templating engine for PHP based on Pug, formerly Jade

319.4k3](/packages/talesoft-tale-pug)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
