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

Binding the master page macro to IBeforeRender. #270

Open
Themanwithoutaplan opened this issue Mar 19, 2016 · 1 comment
Open

Binding the master page macro to IBeforeRender. #270

Themanwithoutaplan opened this issue Mar 19, 2016 · 1 comment

Comments

@Themanwithoutaplan
Copy link
Contributor

This is probably a matter of style but the scaffold suggests that retail views should always call the master template in order to use macros and slots. I think that in this context subscribing to the event makes more sense.

@Themanwithoutaplan
Copy link
Contributor Author

I'd add something like this to the retail.__init__.py or a macros file.

from pyramid.renderers import get_renderer
from pyramid.interfaces import IBeforeRender
from pyramid.events import subscriber


@subscriber(IBeforeRender)
def globals_factory(event):
    master = get_renderer('templates/master.pt').implementation()
    event['master'] = master

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

1 participant