gouthambs / Flask-Blogging

A Markdown Based Python Blog Engine as a Flask Extension.
http://flask-blogging.readthedocs.org/en/latest/
MIT License
690 stars 160 forks source link

Add custom per-view context processors. #65

Closed bendmorris closed 6 years ago

bendmorris commented 8 years ago

Follows the pattern from Flask-Security. This creates context processor decorators which will customize the data passed into blog templates:

@blog_engine.context_processor
def my_data():
    return {'something': 'abc'}

@blog_engine.editor_context_processor
def my_data():
    return {'colors': ['red', 'blue']}

These are very useful when overriding the default templates.

gouthambs commented 8 years ago

The latest version used signals to incorporate a lot of customization. I am in the process of documenting. Could that infrastructure be used to accomplish the same as this approach?

bendmorris commented 8 years ago

The latest version used signals to incorporate a lot of customization. I am in the process of documenting. Could that infrastructure be used to accomplish the same as this approach?

Very possibly. I've met my own needs with this pull request, so you're welcome to either accept it or reimplement it using signals.