1

I am trying to load an external js file using fanstatic. This is how I call the file to be loaded:

<!--[if lt IE 9]>
<%
  h.html5shiv.need()
%>
<![endif]-->

The problem is when I check the source file, the js file is added inside the tag, but not within the IE if check.

<head>
  <script type="text/javascript" src="html5shiv.js"></script>
  <!--[if lt IE 9]>

  <![endif]-->
</head>

Is there a way to force fanstatic to render this js file within the IE if check block?

ericg
  • 103
  • 8

1 Answers1

0

You can use the following:

#import simple js renderer
from fanstatic.core import render_js

#define your custom renderer
def render_conditional_comment_js(url, condition = 'lt', version = '9'):
    return '<!--[if %s IE %s]>%s<![endif]-->' % (condition, version, render_js(url))

#create a library
jquery_lib_conditional = Library('jquery_con', 'lib') 

#use your custom renderer for render a specific resource
jquery_js_conditional = Resource(jquery_lib_conditional, 'jquery-1.9.1.js', renderer = render_conditional_comment_js)