Talesoft / tale-jade

A complete and fully-functional implementation of the Jade template language for PHP

Home Page:http://jade.talesoft.codes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested mixin call before definition error

ArSharlahy opened this issue · comments

Calling in mixin other mixin defined later in same file with params cause Compiler exception

2 0.0289 334680 Tale\Jade\Renderer->render( )
3 0.0342 344896 Tale\Jade\Renderer\Adapter\File->render( ) .../Renderer.php:340
4 0.0361 345432 Tale\Jade\Renderer->compileFile( ) .../File.php:173
5 0.0361 345480 Tale\Jade\Compiler->compileFile( ) .../Renderer.php:316
6 0.0389 347288 Tale\Jade\Compiler->compile( ) .../Compiler.php:542
7 0.6745 1275980 Tale\Jade\Compiler->handleMixins( ) .../Compiler.php:476
8 0.7064 1334288 Tale\Jade\Compiler->handleMixin( ) .../Compiler.php:1268
9 0.7065 1334432 Tale\Jade\Compiler->compileChildren( ) .../Compiler.php:1297
10 0.7065 1334916 Tale\Jade\Compiler->compileNode( ) .../Compiler.php:1892
11 0.7065 1335264 call_user_func:{/adv/vhosts/vsk.a.adv.ru/personal/vendor/talesoft/tale-jade/Compiler.php:925} ( ) .../Compiler.php:925
12 0.7065 1335280 Tale\Jade\Compiler->compileMixinCall( ) .../Compiler.php:925

Following example cause this error:
`mixin a(a)
a= a
+b(a)
mixin b(b)
b=b

+a('a')`

Try to add $ in the mixin to use the variable, and create the mixin b before mixin a.

mixin b(b)
    b=$b

mixin a(a)
    a=$a
    +b(a)

+a('a')

Sorry for not valid example code. I'm use $ in my project. Erorr apears if call b mixin before define it
mixin a(a)
a=$a
+b($a)
mixin b(b)
b=$b

+a('a')

cause
Fatal error: Cannot use object of type Tale\Jade\Parser\Node as array in /adv/vhosts/vsk.a.adv.ru/personal/vendor/talesoft/tale-jade/Compiler.php on line 1441

Their demo site is now closing, so I can't test it now,

Did you indent it with spaces? And can you tried to create mixin b before mixin a?

In your example:

mixin a(a)
    a=$a
    +b(a)

mixin b(b)
    b=$b

+a('a')

Try this:

//- Move `mixin b` ahead.
mixin b(b)
    b=$b

mixin a(a)
    a=$a
    +b(a)

+a('a')

Yeap i indent it right way and if define b before a all works fine, but original jade allow to call mixin and define it later, it's useful when you concat mixins in one file.

Original jade? Did you mean http://jade-lang.com/ ?

Yes

tale-jade is actually not a jade for PHP but a jade-like template engine,

so many things are different, and I guess the creator of tale-jade doesn't implement the function about this,

he's trying to create a new parser for tale-jade, I think that's the answer about it.

I'm just report diference between jade and tale-jade in order to other people that migrate they code on this engine and developer. Error log don't explane what actualy wrong and it was hard for me to find what cause this. I hope this post will help some one who will face the same problem.

Yea, someone mentioned the error is hard to debug before #108

Hello!

This is, indeed, an inconsistency and I will fix it soon.

Sadly, my sites have been taken down, I'm missing my sandbox and the online-docs of Tale Jade currently, I'll need some time to get that all up again (like a week or so)

Tale Jade will receive more active development soon, I'm really sorry, I'm lacking time right now.

I'm also open for PRs, anytime :)

Thank you for work on this project)

I fixed it in the recent commit. Please pull *@dev and check if it works!

I'll close this. I wrote a test mirroring your case and it passes, so it should work.

If it doesn't, feel free to re-open this :)