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

(Flask) Includes don't change upon modification and reloading webpage #49

Open
therealadityashankar opened this issue Mar 21, 2019 · 8 comments

Comments

@therealadityashankar
Copy link

  • pypugjs version: 5.8.0
  • Flask version: 1.0.2
  • Python version: 3.6.7
  • Operating System: Ubuntu 18.04.2 LTS (bionic)

Description

when having a template with an include statement, if the contents of the included templates are changed the page still shows the old included page (perhaps some sort of a caching issue ?), unless the template with the include statement is itself modified

(ps: I understand that you're an active Django dev and this is a Flask issue, I'll hopefully put a pull request shortly)

What I Did

  1. create files with the following structure
app.py
templates/foo.pug
templates/bar.pug
  1. contents of app.py
import flask

app = flask.Flask(__name__)
app.jinja_env.add_extension('pypugjs.ext.jinja.PyPugJSExtension')


@app.route('/')
def foo():
    return flask.render_template('foo.pug')


if __name__ == '__main__':
    app.run(debug=True)
  1. contents of foo.pug
p abc
include bar
  1. contents of bar.pug
p this text does not change
  1. run app.py with python3 app.py
  2. open the webpage on a browser (I am using firefox)
  3. while the app is running modify bar.pug to (DO NOT modify foo.pug)
p i told you so
  1. reload the webpage
  2. (Issue) the webpages' content does not change
  3. modify the contents of foo.pug and save the file, then reload the page
  4. the webpages' content changes
no commands other than running the file, no error traceback
@kakulukia
Copy link
Owner

Well, whats you actual use case that includes changing the templates rather than the displayed data? pypugjs is caching templates and thats probably the reason, why you dont see any update to the template, but that should also happen to any other template that is not included.

Why do you change the templates at all?

@therealadityashankar
Copy link
Author

No this issue does not happen for templates not included (read 9 & 10 of what I did carefully)

A use case for this is updating templates, for better looks and positioning of items, I make small changes and see them change the website, and correct/extend them until these small changes amount to big changes.

This is literally how I've always coded, and in order to modify the included template I've to kill the server and reload it, and that throttles my workflow

@kakulukia
Copy link
Owner

Of course this is a totally valid use case and at least for Django the template caching is deactivated in debug mode. This shall also be the case for Flask and you are welcome to fix that. I see in the code above, that you also have a debug flag, so that this should be a straight forward fix.

@kakulukia
Copy link
Owner

And if you happen to stumble upon the line, where base templates are not cached while debug is off, please also fix that bug as well.

@therealadityashankar
Copy link
Author

Cool, will do, sorry if I sounded a bit rude, have a lovely day 😃 😄

@kakulukia
Copy link
Owner

You didn’t. In case you have some more minutes to spare, it would be awesome if you can check the project docs about the Flask setup for sanity.

@rysev-a
Copy link

rysev-a commented Oct 13, 2020

Hello, i have the same problem with updates included chunks

@kakulukia
Copy link
Owner

Could you supply a test case to fix the problem?

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