Commit 16c9eeb2 authored by Artem Serga's avatar Artem Serga

Add documentation for macro helper

parent 59e03b4d
...@@ -89,6 +89,18 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -89,6 +89,18 @@ class BaseModelView(BaseView, ActionsMixin):
class MyModelView(BaseModelView): class MyModelView(BaseModelView):
column_formatters = dict(price=lambda v, c, m, p: m.price*2) column_formatters = dict(price=lambda v, c, m, p: m.price*2)
or using Jinja2 `macro` in template::
from flask.ext.admin.model.template import macro
class MyModelView(BaseModelView):
column_formatters = dict(price=macro('render_price'))
# in template
{% macro render_price(model, column) %}
{{ model.price * 2 }}
{% endmacro %}
The Callback function has the prototype:: The Callback function has the prototype::
def formatter(view, context, model, name): def formatter(view, context, model, name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment