You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't find equivalents to the url_for('.index') syntax and the Blueprint template_folder keyword argument, so I added a few changes to my fork of Flask-Classy:
FlaskView.url_for(). Adds the view base name to the returned url routes. Things may get inconsistent with bothself.url_for() and url_for() floating around. Maybe it's possible to do something like self.index.url()?
FlaskView.render_template(). Prefixes the template name with the view's template path. Like url_for, it may get confusing.
FlaskView.name. Adds the ability to override the route prefix so it isn't always the class name.
Here's what a sample view looks like with the changes:
class SampleView(FlaskView):
name = 'Prefix' # URL routes are now `Prefix:<method>`
template_path = '/sample/'
def index(self):
if not condition:
return redirect(self.url_for('get', id=12))
else:
return self.render_template('index.html')
def get(self, id):
return self.render_template('thing.html')
Any thoughts or better alternatives that I overlooked while studying the documentation?
The text was updated successfully, but these errors were encountered:
I couldn't find equivalents to the
url_for('.index')
syntax and the Blueprinttemplate_folder
keyword argument, so I added a few changes to my fork of Flask-Classy:FlaskView.url_for()
. Adds the view base name to the returned url routes. Things may get inconsistent with bothself.url_for()
andurl_for()
floating around. Maybe it's possible to do something likeself.index.url()
?FlaskView.render_template()
. Prefixes the template name with the view's template path. Likeurl_for
, it may get confusing.FlaskView.name
. Adds the ability to override the route prefix so it isn't always the class name.Here's what a sample view looks like with the changes:
Any thoughts or better alternatives that I overlooked while studying the documentation?
The text was updated successfully, but these errors were encountered: