Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Docs to as parameter.

  • Loading branch information...
commit c90cc2337792a0c01914c1c780fd13e1aa2bff7e 1 parent 5b7572a
@vbmendes authored
Showing with 42 additions and 1 deletion.
  1. +42 −1 docs/source/index.rst
43 docs/source/index.rst
@@ -159,9 +159,50 @@ django-meio-easytags supports it too::
def querystring(context, **kwargs):
return u'&'.join(u'%s=%s' % (k,v) for k, v in kwargs.items())
- register.tag(querystring)
+ register.easytag(querystring)
With this tag you can build a querystring defining each key and value::
{% querystring key1="1" key2="2" %} # Outputs "key1=1&key2=2
+Using `as` parameter
+Thats a common usage in template tags construction to use a parameter to define a
+variable to receive the content generated by the rendering of the template tag. In
+django-meio-easytags you can use `EasyAsNode` to achieve such a behavior. Just
+override the `EasyAsNode` instead of `EasyNode` and use it in your templates like
+ from django.template import Library
+ from easytags.node import EasyAsNode
+ register = Library()
+ class BasicAsNode(EasyAsNode):
+ def render_context(self, context):
+ return 'basic content to variable'
+ register.tag('basic', BasicAsNode.parse)
+Then load your template tags in your template and use it::
+ {% load my_template_tags %}
+ {% basic as varname %}
+And the Node will store the returning value from `render_context` in a context
+variable name `varname`. Nice, but what about all the library stuff? I can't use
+the `as` parameter and register it in EasyLibrary? Yes you can! Just create your
+method and register it as an `easyastag`::
+ from easytags import EasyLibrary
+ register = EasyLibrary()
+ def basic(context):
+ return 'basic content to variable'
+ register.easytag(basic)
Please sign in to comment.
Something went wrong with that request. Please try again.