Skip to content

Commit

Permalink
[#2618] Cut down to one custom renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 28, 2012
1 parent 4b9cd18 commit 2cccb0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
23 changes: 2 additions & 21 deletions ckan/lib/fanstatic_extensions.py
Expand Up @@ -6,27 +6,8 @@
import fanstatic.core as core


class IEConditionalRenderer(object):
''' Allows for IE conditionals. '''
def __init__(self, condition, renderer, other_browsers=False):
self.condition = condition
self.renderer = renderer
if other_browsers:
self.other_browsers_start = '<!-->'
self.other_browsers_end = '<!--'
else:
self.other_browsers_start = ''
self.other_browsers_end = ''

def __call__(self, url):
return '<!--[if %s]>%s%s%s<![endif]-->' % (self.condition,
self.other_browsers_start,
self.renderer(url),
self.other_browsers_end)


class InlineJSRenderer(object):
''' Allows for in-line js via fanstatic. '''
class CkanCustomRenderer(object):
''' Allows for in-line js and IE conditionals via fanstatic. '''
def __init__(self, script=None, renderer=None, condition=None,
other_browsers=False):
self.script = script
Expand Down
4 changes: 2 additions & 2 deletions ckan/lib/fanstatic_resources.py
Expand Up @@ -89,13 +89,13 @@ def create_resource(path, lib_name, count, inline=False):
other_browsers = ('others' in IE_conditionals[path])
condition = IE_conditionals[path][0]
if inline:
kw['renderer'] = fanstatic_extensions.InlineJSRenderer(
kw['renderer'] = fanstatic_extensions.CkanCustomRenderer(
condition=condition,
script=inline,
renderer=renderer,
other_browsers=other_browsers)
elif condition:
kw['renderer'] = fanstatic_extensions.IEConditionalRenderer(
kw['renderer'] = fanstatic_extensions.CkanCustomRenderer(
condition=condition,
renderer=renderer,
other_browsers=other_browsers)
Expand Down

0 comments on commit 2cccb0b

Please sign in to comment.