pypugjs
pypugjs copied to clipboard
(Flask) Includes don't change upon modification and reloading webpage
- 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
- create files with the following structure
app.py
templates/foo.pug
templates/bar.pug
- 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)
- contents of
foo.pug
p abc
include bar
- contents of
bar.pug
p this text does not change
- run app.py with
python3 app.py
- open the webpage on a browser (I am using firefox)
- while the app is running modify
bar.pug
to (DO NOT modifyfoo.pug
)
p i told you so
- reload the webpage
- (Issue) the webpages' content does not change
- modify the contents of
foo.pug
and save the file, then reload the page - the webpages' content changes
no commands other than running the file, no error traceback
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?
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
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.
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.
Cool, will do, sorry if I sounded a bit rude, have a lovely day :smiley: :smile:
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.
Hello, i have the same problem with updates included chunks
Could you supply a test case to fix the problem?