-
Notifications
You must be signed in to change notification settings - Fork 10
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 block content loses scope #98
Comments
Yeah, this is a real problem. Let me try to explain it. When passing args to the Renderer, a variable called Now, when you do What you can do to solve this: Two methods.
I thought much about this, but it's just the way scoping works in PHP :( |
😱 So for the "refill" option, where exactly does that code go in the example to get it to work? |
Exactly where you current It's just important that you fill You don't need to fill all of them, just those that you need in mixins. I'm thinking about a better way constantly, but I just don't find any since you can basically use any PHP code in Tale Jade |
Crudely simplifying one of my page components, the first
|
Hmm, pretty much all my component mixins accept a |
This actually sucks. I'm currently experimenting with diffing get_defined_vars(), give me some minutes |
Well I think that was too easy in my opinion, I don't believe that it works consistently haha (Not because I did something wrong, but because I don't believe that it actually was that easy) It passes for sure. Please do me a favor and checkout |
Thanks again for all you hard work, this one will be a very handy update 👍 Just got home from work (12:30 am here in Melbourne) and don't have the project/environment setup. I'll be sure to let you know how it goes, hopefully by Monday. |
Ok, so I have tested this out but there is still a problem.
Should output, as Pug does:
But it instead outputs:
|
To give some context, we have a strict component architecture. Each UI component folder contains a JS file, CSS file and a jade template containing a mixin named after the component that accepts a props object as a parameter. Components can import other component mixins at the top with an All of the properties needed to render a given page are set in a single This pattern has worked really well for us in Node. |
Playing around, this workaround works on the new branch:
|
Interesting. I'll work a bit more on this, but merging the scoping mechanism so far |
This is not possible easily in PHP. What you can do is choose a different parameter name for the mixin child(someothernamethantext)
block
mixin parent(text)
p=$text
+child('Child text')
p=$text
+parent('Parent text') |
To give up on this and close the issue is to diverge significantly from the way pug renders. This project is labeled as "A complete and fully-functional implementation of the Jade template language for PHP". The chance that people would next mixins that have the same parameter name is really high, we encountered it immediately in our project but it took a long time to work out the issue. |
I'll keep it opened to point out that it's still an issue, but I currently see no good way around this. Maybe someone else does :) |
In Pug, this:
Renders:
In Tale Jade, the very same renders:
This is a big blocker to porting my Pug templates over, not really sure how to handle it.
The text was updated successfully, but these errors were encountered: