Closed snorfalorpagus closed 9 years ago
@snorfalorpagus please check endpoint_arguments_constructor
on http://flask-breadcrumbs.readthedocs.org/en/latest/#flask.ext.breadcrumbs.register_breadcrumb.
@jirikuncar I had not noticed these arguments. I'm new to using Flask, and some of the terminology is not familiar.
I've managed to do what I wanted using the dynamic_list_constructor
keyword argument - see below. I couldn't figure out how do use endpoint_arguments_constructor
. Is there an easier way I'm missing?
def func(*args, **kwargs):
user_id = request.view_args['user_id']
user = User.query.get(user_id)
return [{'text': user.name, 'url': user.url}]
@main.route('/users/<int:state_id>')
@breadcrumbs.register_breadcrumb(main, '.user', '', dynamic_list_constructor=func)
def view_state(user_id):
...
@snorfalorpagus I'm afraid I don't know any easier way. Do you have any suggestion how to make it simpler? Would you mind creating a pull-request with your example to the package documentation? Thanks
@jirikuncar That's fine. I'll try and get a PR in sometime this week.
@snorfalorpagus any progress with the PR?
How does Flask-Breadcrumbs handle routes with a variable? For example:
In this instance, I'd want the breadcrumb to include a property of the user, not just the ID, e.g.: