Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use jingo.monkey if it exists #58

Merged
merged 1 commit into from

2 participants

@willkg
Owner

This changes funfactory to use jingo.monkey which monkey patches Django
form fields so you don't have to do |safe all the time.

If the available jingo isn't recent enough, then it defaults to using
nuggets safe_django_forms which don't appear to work with Django 1.5
or later.

r?

@willkg willkg Use jingo.monkey if it exists
This changes funfactory to use jingo.monkey which monkey patches Django
form fields so you don't have to do |safe all the time.

If the available jingo isn't recent enough, then it defaults to using
nuggets safe_django_forms which don't appear to work with Django 1.5
or later.
c0e77cc
@fwenzel
Owner

Interesting. Not sure why it moved into jingo though it makes more sense there than in the generic nuggets collection. Thus: r+

@willkg
Owner

It was done in this commit: jbalogh/jingo@4361b9a

Beyond that, I don't know the whys or wherefores.

Thank you for the review!

@willkg willkg merged commit 6b797bb into from
@willkg willkg deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2013
  1. @willkg

    Use jingo.monkey if it exists

    willkg authored
    This changes funfactory to use jingo.monkey which monkey patches Django
    form fields so you don't have to do |safe all the time.
    
    If the available jingo isn't recent enough, then it defaults to using
    nuggets safe_django_forms which don't appear to work with Django 1.5
    or later.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +8 −2 funfactory/monkeypatches.py
View
10 funfactory/monkeypatches.py
@@ -20,8 +20,14 @@ def patch():
# Monkey-patch django forms to avoid having to use Jinja2's |safe
# everywhere.
- import safe_django_forms
- safe_django_forms.monkeypatch()
+ try:
+ import jingo.monkey
+ jingo.monkey.patch()
+ except ImportError:
+ # If we can't import jingo.monkey, then it's an older jingo,
+ # so we go back to the old ways.
+ import safe_django_forms
+ safe_django_forms.monkeypatch()
# Monkey-patch Django's csrf_protect decorator to use session-based CSRF
# tokens:
Something went wrong with that request. Please try again.