diff options
| author | Sean Brant | 2013-03-11 21:53:56 -0500 |
|---|---|---|
| committer | Sean Brant | 2013-03-11 21:53:56 -0500 |
| commit | 1f6755a36658eb0a926ad85a61dc3c14ab3135e3 (patch) | |
| tree | ea800d5bd80c4a245eb686f424fc356efa1deb50 | |
| parent | b9a493e0b729af31d643ff1db1ccca83304d79ca (diff) | |
| download | pykss-1f6755a36658eb0a926ad85a61dc3c14ab3135e3.tar.bz2 | |
Fixes modifier classes inside styleguideblocks
3 files changed, 9 insertions, 9 deletions
diff --git a/examples/djangoproject/djangoproject/templates/styleguide.html b/examples/djangoproject/djangoproject/templates/styleguide.html index 2aa6500..1817a27 100644 --- a/examples/djangoproject/djangoproject/templates/styleguide.html +++ b/examples/djangoproject/djangoproject/templates/styleguide.html @@ -14,7 +14,7 @@ {% endcomment %} {% styleguideblock styleguide "1.1" %} - <button class="{{ modifier.class_name }}">Example Button</button> + <button class="{{ modifier_class }}">Example Button</button> {% endstyleguideblock %} {% verbatim %} @@ -22,7 +22,7 @@ <pre> <code> {% styleguideblock styleguide "1.1" %} - <button class="{{ modifier.class_name }}">Example Button</button> + <button class="{{ modifier_class }}">Example Button</button> {% endstyleguideblock %} </code> </pre> diff --git a/pykss/contrib/django/templatetags/pykss.py b/pykss/contrib/django/templatetags/pykss.py index a99c3ab..a5ad0d5 100644 --- a/pykss/contrib/django/templatetags/pykss.py +++ b/pykss/contrib/django/templatetags/pykss.py @@ -35,7 +35,7 @@ class StyleguideBlockNode(template.Node): modifier_examples = [] for modifier in section.modifiers: - context.update({'modifier': modifier}) + context.update({'modifier_class': ' %s' % modifier.class_name}) html = self.nodelist.render(context).strip() modifier_examples.append({ 'modifier': modifier, @@ -56,11 +56,11 @@ class StyleguideBlockNode(template.Node): def styleguideblock(parser, token): """ {% styleguideblock styleguide "1.1" %} - <button class="{{ modifier.class_name }}">Example Button</button> + <button class="{{ modifier_class }}">Example Button</button> {% endstyleguideblock %} {% styleguideblock styleguide "1.1" using "custom.html" %} - <button class="{{ modifier.class_name }}">Example Button</button> + <button class="{{ modifier_class }}">Example Button</button> {% endstyleguideblock %} """ diff --git a/tests/test_contrib/test_django/test_templatetags/test_pykss.py b/tests/test_contrib/test_django/test_templatetags/test_pykss.py index dc48e41..f066499 100644 --- a/tests/test_contrib/test_django/test_templatetags/test_pykss.py +++ b/tests/test_contrib/test_django/test_templatetags/test_pykss.py @@ -79,7 +79,7 @@ class StyleguideBlockTestCase(TestCase): template = Template(""" {% load pykss %} {% styleguideblock styleguide "2.1.1" using "django.html" %} - <i class="{{ modifier.class_name }}"></i> + <i class="main{{ modifier_class }}"></i> {% endstyleguideblock %} """) context = Context({'styleguide': self.styleguide}) @@ -88,6 +88,6 @@ class StyleguideBlockTestCase(TestCase): self.assertEqual(results['filename'], 'buttons.css') self.assertEqual(results['description'], 'Your standard form button.') self.assertEqual(results['modifiers'][0], [':hover', 'Highlights when hovering.']) - self.assertEqual(results['example_html'], '<i class=""></i>') - self.assertEqual(results['modifier_examples'][0], [':hover', '<i class="pseudo-class-hover"></i>']) - self.assertEqual(results['escaped_html'], '<i class=""></i>') + self.assertEqual(results['example_html'], '<i class="main"></i>') + self.assertEqual(results['modifier_examples'][0], [':hover', '<i class="main pseudo-class-hover"></i>']) + self.assertEqual(results['escaped_html'], '<i class="main"></i>') |
