inveniosoftware / inveniosoftware/flask-breadcrumbs
Can we get a better example of a dynamic list constructor?
- Dominant language
- Python
- Stars
- 30
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
I just cannot figure out how to use the dynamic list constructor for variable rules from the example in the documentation.
Could we get another example?
My question that I don't see addressed in the examples are,
- What parameters gets passed `view_user_dlc`? When I try this out, it appears that no arguments get passed to this function at all.
- What is the significance of the `'.user.id'` and `''` parameters passed to the `register_breadcrumb` decorator? Are they just placeholders without any significance at all?
- In `view_user_dlc`, what is `User`, and where did that come from? I assume that is a global that is part of the application, but that is never explained.
I have looked at the test routines in the flask-breadcrumbs repo for a hint but the single test program does not demonstrate breadcrumbs on variable content. Any help would be appreciated.
```
from flask import request, render_template
def view_user_dlc(*args, **kwargs):
user_id = request.view_args['user_id']
user = User.query.get(user_id)
return [{'text': user.name, 'url': user.url}]
@app.route('/users/')
@breadcrumbs.register_breadcrumb(app, '.user.id', '',
dynamic_list_constructor=view_user_dlc)
def view_user(user_id):
user = User.query.get(user_id)
return render_template('user.html', user=user)
```
Contributor guide
Assessment
This issue has not been assessed yet.