示例#1
0
 def compile_templates(self, paths):
     compiled = ""
     if not paths:
         return compiled
     namespace = settings.PIPELINE_TEMPLATE_NAMESPACE
     base_path = self.base_path(paths)
     for path in paths:
         contents = self.read_file(path)
         if settings.PIPELINE_TEMPLATE_TRANSLATOR:
             translator = to_class(settings.PIPELINE_TEMPLATE_TRANSLATOR)
             if translator:
                 translator = translator(contents)
                 contents = translator.translate_content()
         contents = re.sub(r"\r?\n", "\\\\n", contents)
         contents = re.sub(r"'", "\\'", contents)
         name = self.template_name(path, base_path)
         compiled += "%s['%s'] = %s('%s');\n" % (
             namespace,
             name,
             settings.PIPELINE_TEMPLATE_FUNC,
             contents
         )
     compiler = TEMPLATE_FUNC if settings.PIPELINE_TEMPLATE_FUNC == DEFAULT_TEMPLATE_FUNC else ""
     return "\n".join([
         "%(namespace)s = %(namespace)s || {};" % {'namespace': namespace},
         compiler,
         compiled
     ])
示例#2
0
 def _test_compiler(self, compiler_cls_str, infile, expected):
     compiler_cls = to_class(compiler_cls_str)
     compiler = compiler_cls(verbose=False, storage=staticfiles_storage)
     infile_path = staticfiles_storage.path(infile)
     outfile_path = compiler.output_path(infile_path, compiler.output_extension)
     compiler.compile_file(_(infile_path), _(outfile_path), force=True)
     with open(outfile_path) as f:
         result = f.read()
     with staticfiles_storage.open(expected) as f:
         expected = f.read()
     self.assertEqual(smart_bytes(result), expected)
示例#3
0
 def _test_compiler(self, compiler_cls_str, infile, expected):
     compiler_cls = to_class(compiler_cls_str)
     compiler = compiler_cls(verbose=False, storage=staticfiles_storage)
     infile_path = staticfiles_storage.path(infile)
     outfile_path = compiler.output_path(infile_path, compiler.output_extension)
     compiler.compile_file(_(infile_path), _(outfile_path), force=True)
     with open(outfile_path) as f:
         result = f.read()
     with staticfiles_storage.open(expected) as f:
         expected = f.read()
     self.assertEqual(smart_bytes(result), expected)
示例#4
0
 def css_compressor(self):
     return to_class(settings.PIPELINE_CSS_COMPRESSOR)
示例#5
0
 def compilers(self):
     return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS]
示例#6
0
 def compilers(self):
     return [to_class(compiler) for compiler in settings.COMPILERS]
示例#7
0
 def precompilers(self):
     return [to_class(precompiler) for precompiler in settings.PIPELINE_PRECOMPILERS]
示例#8
0
 def css_compressor(self):
     return to_class(settings.PIPELINE_CSS_COMPRESSOR)
 def js_compressor(self):
     return to_class(settings.JS_COMPRESSOR)
示例#10
0
 def js_compressor(self):
     return to_class(settings.JS_COMPRESSOR)
示例#11
0
 def versioner(self):
     return to_class(settings.PIPELINE_VERSIONING)(self)
示例#12
0
 def versioner(self):
     return to_class(settings.PIPELINE_VERSIONING)(self)
示例#13
0
 def precompilers(self):
     return [
         to_class(precompiler)
         for precompiler in settings.PIPELINE_PRECOMPILERS
     ]