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

Mixin Blocks not supported in Django #285

Closed
pykong opened this issue Aug 30, 2018 · 11 comments
Closed

Mixin Blocks not supported in Django #285

pykong opened this issue Aug 30, 2018 · 11 comments

Comments

@pykong
Copy link

pykong commented Aug 30, 2018

One of the most powerful features of pug is the easy adding of content to mixins via blocks.
Unfortunately this feature does not work with Django as of the current stable release of pyjade/pypugjs.
See:

raise CurrentlyNotSupported("The mixin blocks are not supported yet.")

Is there maybe any workaround to this limitation?
e.g. I tried to specify Jinja2 as an alternative template engine for Django, with pyjade as extension.
But I could not get it to render any pug code.

In lieu of a PR to add the feature to pyjade in the first place:
If there is any such workaround to get pyjade/pypugjs to support mixin blocks in Django such would be very helpful to be added to the docs.

@kakulukia
I summon you here, as you maintain a major fork of pyjade and hence have something to add.
Also, in response to your question in #224. Yes, I am a heavy user of mixins, as it allows to DRY-out much boilerplate code.

@kakulukia
Copy link

Like i said before:

I'll be happy to merge this into the next version (of pypugjs) if you resubmit the PR to my repo.

pyjade kinda seems abandoned :/

@pykong
Copy link
Author

pykong commented Aug 30, 2018

@kakulukia Thanks for your response.
Indeed pyjade appears to be abandonware as of now.

Pardon my ignorance, but you suggesting there is already a fix for this issue in discussion?
(I am not familiar with the code base of pyjade/pypugjs, thus I can not tax the scope of the #224.)
If so:, In lieu of any help from the pyjade maintainers, what work do we need to do in order to implement this fix?

@kakulukia
Copy link

Oh i misunderstood your post before and thought you were the author of that mentioned ticket since you were answering me. Forget about that. :)

Though im a big fan of pypugjs and pyjade before that, i cant say the same about that codebase. I cant even make an educated judgement about it since i never wrote a parser, but it looks very complicated, so i only touched it where i felt it was necessary.
Regarding mixins, so far i havent really used them and didnt feel the need to advance with makeing pypugjs better in that field.
It supports mixins as such, but please elaborate how mixins via blocks are supposed to work. I gues i dont know that feature yet.

@pykong
Copy link
Author

pykong commented Aug 31, 2018

@kakulukia I have difficulty imagining how someone would go about using pug without employing mixins at all. They are such a powerful feature, which can literally eliminate so much boilerplate.

Particularly block mixins is what I like.
Have a look here on what they are on how to use them for your advantage:
https://pugjs.org/language/mixins.html#mixin-blocks

@kakulukia
Copy link

Okay, thanx for the clarification.
Well, needing mixinis or not totally depends on your use case and if stuff is repeating itself over and over again. Im most of the times coding the frontend with VueJS and its components pretty much do the job of you are solving with mixins.

@pykong
Copy link
Author

pykong commented Sep 1, 2018

@kakulukia
Ah, I see. I was thinking of a pure pug use case.
Well, if you use some JS framework it totally makes sense to use its inbuilt templating, especially since it is of dynamic nature vs rendering the HTML once like any HTML preprocessor.

Back to topic:
I suppose there is not a quick fix for the django block mixin at hand? Like a PR that just needs some polishing?

@kakulukia
Copy link

Well, i fear there is no quick fix. But if you feel comfortable looking at the parser, please do! But like i said above, i didnt write it nor can i tell you where to start because i constantly think im missing out on the core concept of how the parse is designed to work. It looks complicated (or im thinking complicated) and i currently dont have enough time to investigate.

But since mixins do work in pypugjs, the blocks shouldnt be that hard to implement.

@kakulukia
Copy link

Please remove any mentions of pyjade and reopen this ticket at pypugjs instead as pyjade will just confuse people and let them send their pull request here, where it probably wont be merged.

@pykong
Copy link
Author

pykong commented Sep 3, 2018

@kakulukia
One can not close bounties at bountysource, AFAIK.
But I will reopen at pypugjs in case the other issue on django-jinja does not get solved.

@pykong
Copy link
Author

pykong commented Sep 3, 2018

It appears using jinja2 as an intermediate allows to use block mixins.

@pykong pykong closed this as completed Sep 3, 2018
@johnmathews
Copy link

@pykong could you explain how you fixed this issue? what do you mean by "using jinja2 as an intermediate" mean?

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

No branches or pull requests

3 participants