jade.php
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:HAML-like template engine for PHP 5.3 & Symfony2
# Jade - template compiler for PHP5.3

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

## Features

  - high performance parser
  - great readability
  - contextual error reporting at compile & run time
  - html 5 mode (using the _!!! 5_ doctype)
  - combine dynamic and static tag classes
  - no tag prefix
  - clear & beautiful HTML output
  - filters
    - :php
    - :cdata
    - :css
    - :javascript
  - you even can write & 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

    $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

### Line Endings

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

### Indentation

Jade is indentation based, however currently only supports a _2 space_ indent.

### 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 `` & 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` => ``). ### 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 ul li one li two li three ### 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 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 ### Jade Comments Jade supports sharp comments (`//- COMMENT`). So jade block: //- JADE - $foo = "
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。