removed usage of JINJA2_FORCED
This commit is contained in:
@@ -72,8 +72,6 @@ class CompressorConf(AppConf):
|
|||||||
def JINJA2_GET_ENVIRONMENT():
|
def JINJA2_GET_ENVIRONMENT():
|
||||||
import jinja2
|
import jinja2
|
||||||
return jinja2.Environment()
|
return jinja2.Environment()
|
||||||
# Whether to force offline generation.
|
|
||||||
JINJA2_FORCED = False
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
prefix = 'compress'
|
prefix = 'compress'
|
||||||
|
@@ -2,7 +2,6 @@ from jinja2 import nodes
|
|||||||
from jinja2.ext import Extension
|
from jinja2.ext import Extension
|
||||||
from jinja2.exceptions import TemplateSyntaxError
|
from jinja2.exceptions import TemplateSyntaxError
|
||||||
|
|
||||||
from compressor.conf import settings
|
|
||||||
from compressor.templatetags.compress import OUTPUT_FILE, CompressorMixin
|
from compressor.templatetags.compress import OUTPUT_FILE, CompressorMixin
|
||||||
|
|
||||||
|
|
||||||
@@ -35,12 +34,16 @@ class CompressorExtension(CompressorMixin, Extension):
|
|||||||
# Skip the kind if used in the endblock, by using the kind in the
|
# Skip the kind if used in the endblock, by using the kind in the
|
||||||
# endblock the templates are slightly more readable.
|
# endblock the templates are slightly more readable.
|
||||||
parser.stream.skip_if('name:' + kindarg.value)
|
parser.stream.skip_if('name:' + kindarg.value)
|
||||||
return nodes.CallBlock(self.call_method('_compress', args), [], [],
|
return nodes.CallBlock(self.call_method('_compress_normal', args), [], [],
|
||||||
body).set_lineno(lineno)
|
body).set_lineno(lineno)
|
||||||
|
|
||||||
def _compress(self, kind, mode, caller):
|
def _compress_forced(self, kind, mode, caller):
|
||||||
forced = settings.COMPRESS_JINJA2_FORCED
|
return self._compress(kind, mode, caller, True)
|
||||||
|
|
||||||
|
def _compress_normal(self, kind, mode, caller):
|
||||||
|
return self._compress(kind, mode, caller, False)
|
||||||
|
|
||||||
|
def _compress(self, kind, mode, caller, forced):
|
||||||
mode = mode or OUTPUT_FILE
|
mode = mode or OUTPUT_FILE
|
||||||
original_content = caller()
|
original_content = caller()
|
||||||
context = {
|
context = {
|
||||||
|
@@ -202,8 +202,6 @@ class Command(NoArgsCommand):
|
|||||||
count = 0
|
count = 0
|
||||||
results = []
|
results = []
|
||||||
offline_manifest = SortedDict()
|
offline_manifest = SortedDict()
|
||||||
old_forced = settings.COMPRESS_JINJA2_FORCED
|
|
||||||
settings.COMPRESS_JINJA2_FORCED = True
|
|
||||||
init_context = parser.get_init_context(settings.COMPRESS_OFFLINE_CONTEXT)
|
init_context = parser.get_init_context(settings.COMPRESS_OFFLINE_CONTEXT)
|
||||||
|
|
||||||
for template, nodes in compressor_nodes.items():
|
for template, nodes in compressor_nodes.items():
|
||||||
@@ -229,7 +227,6 @@ class Command(NoArgsCommand):
|
|||||||
results.append(result)
|
results.append(result)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
settings.COMPRESS_JINJA2_FORCED = old_forced
|
|
||||||
write_offline_manifest(offline_manifest)
|
write_offline_manifest(offline_manifest)
|
||||||
|
|
||||||
log.write("done\nCompressed %d block(s) from %d template(s).\n" %
|
log.write("done\nCompressed %d block(s) from %d template(s).\n" %
|
||||||
|
@@ -119,6 +119,7 @@ class Jinja2Parser(object):
|
|||||||
isinstance(node.call, Call) and
|
isinstance(node.call, Call) and
|
||||||
isinstance(node.call.node, ExtensionAttribute) and
|
isinstance(node.call.node, ExtensionAttribute) and
|
||||||
node.call.node.identifier == self.COMPRESSOR_ID):
|
node.call.node.identifier == self.COMPRESSOR_ID):
|
||||||
|
node.call.node.name = '_compress_forced'
|
||||||
yield node
|
yield node
|
||||||
else:
|
else:
|
||||||
for node in self.walk_nodes(node, block_name=block_name):
|
for node in self.walk_nodes(node, block_name=block_name):
|
||||||
|
Reference in New Issue
Block a user