Rendering functions

flaskext.genshi.render(template, **context)

Render a template to a response object, passing the context as keyword arguments. Shorthand for render_response(template, dict(**context)).

New in version 0.6.

flaskext.genshi.render_response(template=None, context=None, method=None, string=None, filter=None)

Renders a template and wraps it in a response_class with mimetype set according to the rendering method.

flaskext.genshi.render_template(template=None, context=None, method=None, string=None, filter=None)

Renders a template to a string.

Extension Object

class flaskext.genshi.Genshi(app=None)

Initialize extension.

app = Flask(__name__)
genshi = Genshi(app)

Changed in version 0.4: You can now initialize your application later with init_app().

Deprecated since version 0.4: app.genshi_instance in favor of app.extensions['genshi'].


A callable for Genshi’s callback interface, called when a template is loaded, with the template as the only argument.

template_parsed() is a decorator for setting this.

New in version 0.5.


What method is used for an extension.


Decorator that adds a function to apply filters to templates by rendering method.

New in version 0.3.

Changed in version 0.5: Filters can now optionally take a second argument for the context.


Filter functions to be applied to templates.

New in version 0.3.


Initialize a Flask application for use with this extension. Useful for the factory pattern but not needed if you passed your application to the Genshi constructor.

genshi = Genshi()

app = Flask(__name__)

New in version 0.4.


Render methods.

Changed in version 0.3: Support for Javascript and CSS.

Changed in version 0.4: Support for SVG.


A genshi.template.TemplateLoader that loads templates from the same places as Flask.


Set up a calback to be called with a template when it is first loaded and parsed. This is the correct way to set up the Translator filter.

New in version 0.5.



Signal emitted when a template stream has been successfully generated, passing template and context via the app as sender.

New in version 0.5.

Lesser utilities

flaskext.genshi.generate_template(template=None, context=None, method=None, string=None, filter=None)

Creates a Genshi template stream that you can run filters and transformations on.

Table Of Contents

Related Topics