Primary User API¶
- render(template_name, **context)¶
Render a template to a response object.
The rendered result is encoded according to the default charset of the response_class and the MIME type of the response is set to that of the rendered template.
This function requires a Flask request context belonging to an application configured with a Genshi instance.
- render_template(template_name, **context)¶
Render a template to a unicode string.
Like render but returns an unencoded unicode string. Primarily useful for purposes other than rendering responses to HTTP requests, such as e-mail templating. Similar to the function of the same name in Flask.
- class Genshi(app=None)¶
Extension object. Holds configuration for the Flask-Genshi extension.
app = Flask(__name__) genshi = Genshi(app)
You can subscript the instance to get a Template by name, allowing you to apply stream filters with more control.
template = genshi['index.html'] \ | Transformer('//title').replace('Fabulous Ltd.')
Parameters: app – Short for calling init_app. - init_app(app)¶
Configure a Flask application for using this extension.
- mime_db¶
A MimeTypes instance used to look up the ContentType configured for a template.
- content_types¶
Maps MIME types to ContentType instances.
- get_content_type(mimetype)¶
Select the ContentType configured for the mimetype.
- create_context(base)¶
Create a Context for rendering templates in, including at least the items in base.
- create_loader(app)¶
Create a template loader for Genshi based on the template folders configured for app and its blueprints.
- loader_callback(template)¶
Called by template loaders when a template is parsed, but not when it is returned from the cache.
The default emits the template_parsed signal.