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

A few feature suggestions #41

Open
Blender3D opened this issue Jun 25, 2013 · 0 comments
Open

A few feature suggestions #41

Blender3D opened this issue Jun 25, 2013 · 0 comments

Comments

@Blender3D
Copy link

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?

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