API

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'].

callback

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.

extensions

What method is used for an extension.

filter(*methods)

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.

filters

Filter functions to be applied to templates.

New in version 0.3.

init_app(app)

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__)
genshi.init_app(app)

New in version 0.4.

methods

Render methods.

Changed in version 0.3: Support for Javascript and CSS.

Changed in version 0.4: Support for SVG.

template_loader

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

template_parsed(callback)

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.

Signals

flaskext.genshi.template_generated

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