opendena / jade.php

HAML-like template engine for PHP 5.3
MIT License
18 stars 0 forks source link

Argument 1 passed to Jade\Node::addChild() must be an instance of Jade\Node #2

Closed cyrusdavid closed 11 years ago

cyrusdavid commented 11 years ago
$parser = new \Jade\Parser(new \Jade\Lexer());
$dumper = new \Jade\Dumper();
$jade = new \Jade\Jade($parser, $dumper);

$html = <<<EOF
!!! 5
  html
EOF;
exit(var_dump(($jade->render($html)));
cyrusdavid commented 11 years ago
$html ="!!! 5
  html
    title Hello World";
exit(var_dump(($jade->render($html)));

The same happens.

SebastienElet commented 11 years ago

Hello,

Thanks for your report, i did several tests and this is not a bug. Jade does not expect any indent after the doctype declaration.

Your template is also invalid with native jade.

The fallowing code works

$parser = new \Jade\Parser(new \Jade\Lexer());
$dumper = new \Jade\Dumper();
$jade = new \Jade\Jade($parser, $dumper);

$html = <<<EOF
!!! 5
html
EOF;
exit(var_dump($jade->render($html)));

I admit the error message should be smarter (like the js one)

Error: test.jade:2
    1| !!! 5
  > 2|   html
    3|     title Hello
    4|

unexpected token "indent"
cyrusdavid commented 11 years ago

Oh, haha. Sorry about that.

SebastienElet commented 11 years ago

No problem, your issue pointed a serious lack of information for such error.

cyrusdavid commented 11 years ago

btw, can I pass an option/argument somewhere to enable/disable pretty-print?

SebastienElet commented 11 years ago

Could you open another issue with some examples of what you want to do please ?