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

Pre/Post hooks #85

Open
svetozarstojkovic opened this issue Sep 16, 2019 · 4 comments
Open

Pre/Post hooks #85

svetozarstojkovic opened this issue Sep 16, 2019 · 4 comments

Comments

@svetozarstojkovic
Copy link
Contributor

Last week @starsinmypockets and I came across a weird behaviour while implementing 'ckan_pages' plugin.

  1. '/' endpoint was overwritten in the theme index.js file.
  2. in the plugin I tried to add a session variable that can be used in nunjucks template.

The problem was that the theme endpoint was executed before the plugin and there res.render function was called and we get an html page before variable from the plugin was set.

The proposal is to create prehooks and posthooks in .env file that will tell which plugins will be executed before and which will be executed after the theme.

By adding that we will have more control when opening some page.

Prehooks will be used for plugins that set variables that need to be used in nunjucks template.
Posthooks will be used for plugins that override some endpoints.

@anuveyatsu what do you think about this idea?

@anuveyatsu
Copy link
Member

@svetozarstojkovic I think plugins shouldn't override existing routes but add variables into the response so that they can be used in the view. I've created specific issue re WP here #86

@anuveyatsu
Copy link
Member

@svetozarstojkovic here we implemented some changes that can resolve this issue #87

@svetozarstojkovic
Copy link
Contributor Author

svetozarstojkovic commented Sep 18, 2019

@anuveyatsu @sagargg can this ticket be closed then?

Also should we update README.md with new instructions, so anyone new would know how exactly to write new plugins?

@anuveyatsu
Copy link
Member

Agree re docs @svetozarstojkovic

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

2 participants