Coder Social home page Coder Social logo

sisoftrg / jade.php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hackaugusto/jade.php

42.0 42.0 11.0 522 KB

Jade template engine ported to PHP 5.3

Home Page: https://github.com/visionmedia/jade

License: MIT License

PHP 29.25% CSS 36.80% JavaScript 33.96%
jade jade-template-engine php

jade.php's People

Contributors

djranger avatar everzet avatar fcrosfly avatar hackaugusto avatar hkjels avatar lukegb avatar peniar avatar sadjow avatar sheershoff avatar sisoftrg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jade.php's Issues

Example

This seems to be the most recent fork of jade.php Nice to see someone still working on it.

I couldn't figure out how to use the original jade.php nor am I able figure out this jade.php
How do I use it? (I know Jade from express.js) Could you give a quick example?

Thx!

Sam

data-* rendered with double quotes

Hi!

First of all, thumbs up for the port to PHP! Works like a charm to use it on client and server. I have a little problem with html5 data-attributes tho:

div(data-module="#{mod}", class="#{module_classes}") 

renders as

<div data-module=""something"" class="some classes here">

Please notice the double quotes around the data-module value.
The problem only happens with a variable + data- attributes.

div(data-module="something", class="#{module_classes}") 

OK, constant works as expected

div(module="#{mod}", class="#{module_classes}") 

OK, as expected, but of course creates invalid html.

It works perfectly with Jade client-side. Might there be a
Javascript + not ported or something?

Any help appreciated!

Pass functions to the view

I'm trying to pass a static function to a view, wrapping in an anonymous function before rendering to the file. The problem is that, the function becomes a variable (in my case $url, and I was expecting it to be named url (that behaves like Javascript Jade). I can call the $url('/') stuff, but I'm avoiding using PHP in the views because I can later on, exchange the server stuff to node.js without hassle

Various issues with automatic adding of $-sign to variable names.

I am running into many problems with the automatic variable name substitution, and start to believe it's not a good idea to do this. For example, this code is causing issues:

open = pages->findOpen()
items = open ? open->children()->visible() : false

This gets wrongly translated to:

$__=$pages->findOpen();
$open  = $__
$__=$open ? open->children()->visible() : false;
$items  = $__
 ?>

As you can see, in the second statement, the second occurrence of open does not get replaced.

I have therefore created my own version of jade.php that removes this variable translation, and explicitly use the $-sign in the templates: https://github.com/lehni/jade.php

Don't you think this would make more sense for a PHP based Jade? I am wondering what the official take is on these kind of problems?

Wrong parsing of PHP style foreach

I tried this in a template:

- foreach($pages->visible() as $p):

And it was wrongly translated to:

<?php for(each($pages->visible() as $p)) { ?>

Use isset to avoid E_NOTICE

It's a good practice to use isset when doing an if on a variable that is in the view (since it might not be initialized at that time). since javascript doesn't trigger an error (at least not in strict mode) when doing an if on an undefined, PHP, on the other hand, when E_ALL is set (in development of course), it will trigger the notice. I don't know where to change this code, so that's the reason I'm opening the issue

extract call in render is useless?

I couldn't track down the use of this bit of code:

        if ($scope !== null && is_array($scope)) {
            extract($scope);
        }

inside render() function. There are no includes or requires, so it's kinda leading to nowhere.

Bad compiling (test.php)

Hi,

I'm using turnkey virtual machine (Debian + PHP 5.3):
http://www.turnkeylinux.org/lampstack

And some templates are compiling with errors. Here is result of test.php:

root@lamp jade/tests# php test.php
* rendering test 'attrs-data'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/attrs-data.jade.php on line 2
  -<foodata-user='{'name':'tobi'}'></foo><foodata-items='[1,2,3]'></foo><foodata-username='tobi'></foo>
  +

* rendering test 'attrs.interpolation'
* rendering test 'attrs'
* rendering test 'attrs.js'
* rendering test 'attrs.unescaped'
  -<scripttype='text/x-template'><divid='user-<%=user.id%>'><h1><%=user.title%></h1></div></script>
  +<scripttype='text/x-template'><divid='user'id='user-<%=user.id%>'><h1><%=user.title%></h1></div></script>

* rendering test 'basic'
* rendering test 'blanks'
* rendering test 'block-expansion'
* rendering test 'block-expansion.shorthands'
* rendering test 'blockquote'
* rendering test 'case-blocks'
* rendering test 'case'
* rendering test 'classes-empty'
* rendering test 'classes'
* rendering test 'code.conditionals'
* rendering test 'code.escape'
* rendering test 'code.iteration'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/code.iteration.jade.php on line 2
  -<ul><liclass='item-0'>1</li><liclass='item-1'>2</li><liclass='item-2'>3</li></ul><ul><li>1</li><li>2</li><li>3</li></ul><ul><li>1:a</li><li>2:a</li><li>3:a</li><li>1:b</li><li>2:b</li><li>3:b</li><li>1:c</li><li>2:c</li><li>3:c</li></ul>
  +

* rendering test 'code'
* rendering test 'comments.conditional'
* rendering test 'comments'
* rendering test 'deep-arrays'
* rendering test 'doctype.custom'
* rendering test 'doctype.default'
* rendering test 'doctype.keyword'
* rendering test 'each.else'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/each.else.jade.php on line 2
  -<ul><li>nousers!</li></ul><ul><li>tobi</li><li>loki</li></ul>
  +

* rendering test 'escape-chars'
* rendering test 'filters.cdata'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/filters.cdata.jade.php on line 2
  -<fb:users><fb:userage='2'><![CDATA[tobi]]></fb:user></fb:users>
  +

* rendering test 'html'
* rendering test 'html5'
* rendering test 'if-parentheses'
* rendering test 'include-extends-of-common-template'
* rendering test 'include-only-text-body'
* rendering test 'include-only-text'
* rendering test 'include-with-text-head'
* rendering test 'include-with-text'
  -<html><head><scripttype='text/javascript'>alert('helloworld');</script><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script></head></html>
  +<html><head><scripttype='text/javascript'>alert('helloworld');</script></head><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script></html>

* rendering test 'include.script'
* rendering test 'include.yield.nested'
  -<html><head><title></title></head><body><h1>Page</h1><divid='content'><divid='content-wrapper'><p>somecontent</p><p>andsomemore</p></div></div><divid='footer'><stuff></stuff></div></body></html>
  +<html><head><title></title></head><body><h1>Page</h1><divid='content'><divid='content-wrapper'></div></div><divid='footer'><stuff></stuff></div></body></html><p>somecontent</p><p>andsomemore</p>

* rendering test 'includes'
* rendering test 'inheritance.alert-dialog'
* rendering test 'inheritance.defaults'
* rendering test 'inheritance.extend.include'
* rendering test 'inheritance.extend'
* rendering test 'inheritance.extend.mixins'
  -<html><head><title>MyApplication</title></head><body><h1>Themeaningoflife</h1><p>Foobarbaz!</p></body></html>
  +<html><head><title>MyApplication</title></head><body><h1>Themeaningoflife</h1></body></html>

* rendering test 'inheritance.extend.whitespace'
* rendering test 'inheritance'
* rendering test 'interpolation.escape'
* rendering test 'mixin-hoist'
* rendering test 'mixin.attrs'
PHP Warning:  Missing argument 2 for centered_mixin(), called in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/mixin.attrs.jade.php on line 37 and defined in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/mixin.attrs.jade.php on line 1
  -<body><divid='First'class='centered'>HelloWorld</div><divid='Second'class='centered'><h1>Section1</h1><p>Someimportantcontent.</p></div><divid='Third'class='centered'><h1class='foobar'>Section2</h1><p>Evenmoreimportantcontent.</p><divclass='footer'><ahref='menu.html'>Back</a></div></div><divclass='stretch'><divclass='centered'><h1class='highlight'>Section3</h1><p>Lastcontent.</p><divclass='footer'><ahref='#'>Back</a></div></div></div><divclass='bottomfoobar'name='end'id='Last'data-attr='baz'><p>Somefinalwords.</p></div></body>
  +<body><divid=''First''class='centered'></div><divid=''Second''class='centered'><h1class=''>Section1</h1></div><divid=''Third''class='centered'><h1class=''bar''>Section2</h1><divclass='footer'><ahref=''menu.html''>Back</a></div></div><divclass='stretch'><divid=''class='centered'><h1class=''highlight''>Section3</h1><divclass='footer'><ahref=''#''>Back</a></div></div></div><divattributes='attributes'class='bottom'></div></body>

* rendering test 'mixin.block-tag-behaviour'
  -<html><body><sectionclass='article'><h1>Foo</h1><p>I'marticlefoo</p></section></body></html><html><body><sectionclass='article'><h1>Something</h1><p>I'mamuchlongertext-onlyarticle,butyoucanstillinlinehtmltagsinmeifyouwant.</p></section></body></html>
  +<html><body><sectionclass='article'><h1>Foo</h1><p></p></section></body></html><html><body><sectionclass='article'><h1>Something</h1><p></p></section></body></html>

* rendering test 'mixin.blocks'
  -<html><body><formmethod='GET'action='/search'><inputtype='hidden'name='_csrf'value='hey'/><inputtype='text'name='query'placeholder='Search'/><inputtype='submit'value='Search'/></form></body></html><html><body><formmethod='POST'action='/search'><inputtype='hidden'name='_csrf'value='hey'/><inputtype='text'name='query'placeholder='Search'/><inputtype='submit'value='Search'/></form></body></html><html><body><formmethod='POST'action='/search'><inputtype='hidden'name='_csrf'value='hey'/></form></body></html><divid='foo'><divid='bar'><p>one</p><p>two</p><p>three</p></div></div>
  +<html><body><formmethod='GET'action='/search'><inputtype='hidden'name='_csrf'value='hey'/></form></body></html><html><body><formmethod='POST'action='/search'><inputtype='hidden'name='_csrf'value='hey'/></form></body></html><html><body><formmethod='POST'action='/search'><inputtype='hidden'name='_csrf'value='hey'/></form></body></html><divid='foo'><divid='bar'></div></div>

* rendering test 'mixin.merge'
  -<body><pclass='barhello'>One</p><pclass='bazquuxhello'>Two</p><pclass='hello'>Three</p><pclass='barbazhello'>Four</p><pclass='bar'id='world'>One</p><pclass='bazquux'id='world'>Two</p><pid='world'>Three</p><pclass='barbaz'id='world'>Four</p><pclass='barhello'id='world'>One</p><pclass='bazquuxhello'id='world'>Two</p><pclass='hello'id='world'>Three</p><pclass='barbazhello'id='world'>Four</p><pclass='barhelloworld'>One</p><pclass='bazquuxhelloworld'>Two</p><pclass='helloworld'>Three</p><pclass='barbazhelloworld'>Four</p><pclass='barhello'>One</p><pclass='bazquuxhello'>Two</p><pclass='hello'>Three</p><pclass='barbazhello'>Four</p><pclass='barhelloworld'>One</p><pclass='bazquuxhelloworld'>Two</p><pclass='helloworld'>Three</p><pclass='barbazhelloworld'>Four</p><pclass='bar'>One</p><pclass='bazquux'>Two</p><p>Three</p><pclass='barbaz'>Four</p></body>
  +<body><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p><pattributes='attributes'class='bar'>One</p><pattributes='attributes'class='bazquux'>Two</p><pattributes='attributes'>Three</p><pattributes='attributes'class='barbaz'>Four</p></body>

* rendering test 'mixins'
* rendering test 'namespaces'
* rendering test 'nesting'
* rendering test 'quotes'
* rendering test 'scope'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/scope.jade.php on line 18
  -testtest2
  +

* rendering test 'script.whitespace'
* rendering test 'scripts'
* rendering test 'scripts.non-js'
* rendering test 'source'
* rendering test 'styles'
* rendering test 'tag.interpolation'
  -<p>value</p><pfoo='bar'>value</p><asomething='something'>here</a><ul><li><span><imgsrc='contact'class='icon'/>Contact</span></li><li><ahref='/contact'><imgclass='icon'/>Contact</a></li></ul>
  +<tag>value</tag><tagfoo='bar'>value</tag><foo?'a':'li'something='something'>here</foo?'a':'li'><ul><li><spanattributes='attributes'><imgsrc='contact'class='icon'/></span></li><li><spanattributes='attributes'><imgsrc='/contact'class='icon'/></span></li></ul>

* rendering test 'tags.self-closing'
* rendering test 'template'
* rendering test 'text-block'
* rendering test 'text'
* rendering test 'utf8bom'
* rendering test 'utf8params'
* rendering test 'vars'
PHP Parse error:  syntax error, unexpected '(' in /var/www/fakty_prod/application/vendor/sisoft/jade/tests/vars.jade.php on line 3
  -<aid='bar'class='123'></a>
  +

* rendering test 'yield-before-conditional-head'
* rendering test 'yield-before-conditional'
  -<html><body><head><scriptsrc='/jquery.js'></script><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script></head></body></html>
  +<html><body><head><scriptsrc='/jquery.js'></script></head><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script></body></html>

* rendering test 'yield-head'
* rendering test 'yield-title-head'
* rendering test 'yield-title'
  -<html><body><head><title>MyTitle</title><scriptsrc='/jquery.js'></script><scriptsrc='/jquery.ui.js'></script></head></body></html>
  +<html><body><head><title></title><scriptsrc='/jquery.js'></script><scriptsrc='/jquery.ui.js'></script></head>MyTitle</body></html>

* rendering test 'yield'
  -<html><body><head><scriptsrc='/jquery.js'></script><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script><scriptsrc='/jquery.ui.js'></script></head></body></html>
  +<html><body><head><scriptsrc='/jquery.js'></script><scriptsrc='/jquery.ui.js'></script></head><scriptsrc='/caustic.js'></script><scriptsrc='/app.js'></script></body></html>

Scope Resolution :: Error

Hi :)

This line:
= Yii::app()->request->baseUrl

is translated in a wrong way:

<?php $__=$Yii::app();echo htmlspecialchars($__) ?>

This line:
- $baseUrl = Yii::app()->request->baseUrl

is translated in the right way:

<?php $baseUrl = Yii::app()->request->baseUrl ?>

No problem with this too:

- $app = Yii::app()
= $app->request->baseurl

I think the bug is due to the php scope resolution operator ::

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.