PHPackages                             marcwoozie/jade-php - 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. marcwoozie/jade-php

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

marcwoozie/jade-php
===================

HAML-like template engine for PHP 5.3

06PHP

Since Sep 4Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/87bbd282eac083e420f3c05996eff9a5184b4220d35d3104192cd7d5caa2f877?d=identicon)[marcwoozie](/maintainers/marcwoozie)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

555.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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