From 026b0cb60208aaffe666aff7d772ea44b0a07019 Mon Sep 17 00:00:00 2001 From: Martin Koistinen Date: Mon, 16 Feb 2015 00:09:57 -0500 Subject: [PATCH] Add docs for new tag --- docs/reference/templatetags.rst | 57 ++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/docs/reference/templatetags.rst b/docs/reference/templatetags.rst index aaa39d045b..1ec22ffa10 100644 --- a/docs/reference/templatetags.rst +++ b/docs/reference/templatetags.rst @@ -609,9 +609,12 @@ It will render to something like: Icon and position can be customized via CSS by setting a background to the ``.cms_render_model_add img`` selector. -..warning:: +.. warning:: - You **must** pass an instance of your model as instance parameter. + You **must** pass an *instance* of your model as instance parameter. The + instance passed could be an existing models instance, or one newly created + in your view/plugin. It does not even have to be saved, it is introspected + by the templatetag to determine the desired model class. **Arguments:** @@ -631,9 +634,55 @@ It will render to something like: .. _django-hvad: https://github.com/kristianoellegaard/django-hvad - {% endblock %} -.. templatetag:: page_language_url +render_model_add_block +====================== + +``render_model_add_block`` is similar to ``render_model_add`` but instead of +emitting an icon that is linked to the add model form in a modal dialog, it +wraps arbitrary markup with the same "link". This allows the developer to create +front-end editing experiences better suited to the project. + +All arguments are identical to ``render_model_add``, but the templatetag is used +in two parts to wrap the markup that should be wrapped. + +.. code-block:: html+django + + {% render_model_add_block my_model_instance %}
New Object
{% endrender_model_add_block %} + + +It will render to something like: + +.. code-block:: html+django + +
+
New Object
+
+ + +.. warning:: + + You **must** pass an *instance* of your model as instance parameter. The + instance passed could be an existing models instance, or one newly created + in your view/plugin. It does not even have to be saved, it is introspected + by the templatetag to determine the desired model class. + + +**Arguments:** + +* ``instance``: instance of your model in the template +* ``edit_fields`` (optional): a comma separated list of fields editable in the + popup editor; +* ``language`` (optional): the admin language tab to be linked. Useful only for + `django-hvad`_ enabled models. +* ``view_url`` (optional): the name of a url that will be reversed using the + instance ``pk`` and the ``language`` as arguments; +* ``view_method`` (optional): a method name that will return a URL to a view; + the method must accept ``request`` as first parameter. +* ``varname`` (optional): the templatetag output can be saved as a context + variable for later use. + +.. _django-hvad: https://github.com/kristianoellegaard/django-hvad page_language_url