1

我正在尝试使用 fanstatic 加载外部 js 文件。这就是我调用要加载的文件的方式:

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

问题是当我检查源文件时,js文件被添加到标签内,但不是在IE中检查。

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

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

如果检查块,有没有办法强制 fanstatic 在 IE 中呈现这个 js 文件?

4

1 回答 1

0

您可以使用以下内容:

#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)
于 2014-03-17T09:52:26.553 回答