本文整理汇总了Python中compressor.css.CssCompressor.output_inline方法的典型用法代码示例。如果您正苦于以下问题:Python CssCompressor.output_inline方法的具体用法?Python CssCompressor.output_inline怎么用?Python CssCompressor.output_inline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compressor.css.CssCompressor
的用法示例。
在下文中一共展示了CssCompressor.output_inline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from compressor.css import CssCompressor [as 别名]
# 或者: from compressor.css.CssCompressor import output_inline [as 别名]
def render(self, context, compress=settings.COMPRESS, offline=settings.OFFLINE):
if compress and offline:
key = get_offline_cachekey(self.nodelist)
content = cache.get(key)
if content:
return content
content = self.nodelist.render(context)
if offline or not compress or not len(content.strip()):
return content
if self.kind == 'css':
compressor = CssCompressor(content)
if self.kind == 'js':
compressor = JsCompressor(content)
cachekey = "%s-%s" % (compressor.cachekey, self.mode)
output = self.cache_get(cachekey)
if output is None:
try:
if self.mode == OUTPUT_FILE:
output = compressor.output()
else:
output = compressor.output_inline()
self.cache_set(cachekey, output)
except:
from traceback import format_exc
raise Exception(format_exc())
return output