Commits

pahaz committed 976396d

new version 1.1.2

add support template varible in ``render_field`` tag.

  • Participants
  • Parent commits 154148f

Comments (0)

Files changed (1)

File widget_tweaks/templatetags/widget_tweaks.py

 def set_data(field, data):
     return set_attr(field, 'data-' + data)
 
+# render_field tag
 
 ATTRIBUTE_RE = re.compile(r"""
     (?P<attr>
     (?P<sign>
         \+?=
     )
+    (?P<value>
     ['"]? # start quote
-    (?P<value>
         [^"']*
+    ['"]? # end quote
     )
-    ['"]? # end quote
 """, re.VERBOSE | re.UNICODE)
 
 @register.tag
         if not match:
             raise TemplateSyntaxError(error_msg + ": %s" % pair)
         dct = match.groupdict()
-        attr, sign, value = dct['attr'], dct['sign'], dct['value']
+        attr, sign, value = dct['attr'], dct['sign'], parser.compile_filter(dct['value'])
         if sign == "=":
             set_attrs.append((attr, value))
         else:
     def render(self, context):
         bounded_field = self.field.resolve(context)
         for k, v in self.set_attrs:
-            bounded_field = set_attr(bounded_field, '%s:%s' % (k,v))
+            bounded_field = set_attr(bounded_field, '%s:%s' % (k,v.resolve(context)))
         for k, v in self.append_attrs:
-            bounded_field = append_attr(bounded_field, '%s:%s' % (k,v))
+            bounded_field = append_attr(bounded_field, '%s:%s' % (k,v.resolve(context)))
         return bounded_field