Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested mixin call before definition error #115

Closed
ArSharlahy opened this issue Jul 7, 2016 · 13 comments
Closed

Nested mixin call before definition error #115

ArSharlahy opened this issue Jul 7, 2016 · 13 comments

Comments

@ArSharlahy
Copy link

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')`

@YamiOdymel
Copy link

YamiOdymel commented Jul 7, 2016

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')

@ArSharlahy
Copy link
Author

ArSharlahy commented Jul 7, 2016

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

@YamiOdymel
Copy link

YamiOdymel commented Jul 7, 2016

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')

@ArSharlahy
Copy link
Author

ArSharlahy commented Jul 7, 2016

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.

@YamiOdymel
Copy link

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

@ArSharlahy
Copy link
Author

Yes

@YamiOdymel
Copy link

YamiOdymel commented Jul 7, 2016

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.

@ArSharlahy
Copy link
Author

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.

@ArSharlahy ArSharlahy reopened this Jul 7, 2016
@YamiOdymel
Copy link

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

@TorbenKoehn
Copy link
Member

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 :)

@ArSharlahy
Copy link
Author

Thank you for work on this project)

TorbenKoehn pushed a commit that referenced this issue Aug 19, 2016
…solved correctly

Addressed #113, classes can now start with a dash

Addressed #112, block expansion now handles following classes correctly

Addressed #108 and improved error handling, including a re-write of most exception messages with more details
@TorbenKoehn
Copy link
Member

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

@TorbenKoehn
Copy link
Member

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants