utf8 content.json fix, faster node.js coffeescript compiler support
This commit is contained in:
parent
1468756691
commit
6cedaa8e8f
2 changed files with 8 additions and 9 deletions
|
@ -40,14 +40,14 @@ def merge(merged_path):
|
||||||
return False # No coffeescript compiler, skip this file
|
return False # No coffeescript compiler, skip this file
|
||||||
command = config.coffeescript_compiler % file_path.replace("/", "\\")
|
command = config.coffeescript_compiler % file_path.replace("/", "\\")
|
||||||
s = time.time()
|
s = time.time()
|
||||||
compiler = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
|
||||||
logging.debug("Running: %s (Done in %.2fs)" % (command, time.time()-s))
|
logging.debug("Running: %s (Done in %.2fs)" % (command, time.time()-s))
|
||||||
source = compiler.stdout.read()
|
out = compiler.stdout.read()
|
||||||
if source:
|
if out and out.startswith("("):
|
||||||
parts.append(source)
|
parts.append(out)
|
||||||
else:
|
else:
|
||||||
error = compiler.stderr.read()
|
error = out
|
||||||
parts.append("alert('%s compile error: %s');" % (file_path, re.escape(error)) )
|
parts.append("alert('%s compile error: %s');" % (file_path, re.escape(error).replace("\n", "\\n").replace(r"\\n", r"\n") ) )
|
||||||
else: # Add to parts
|
else: # Add to parts
|
||||||
parts.append(open(file_path).read())
|
parts.append(open(file_path).read())
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,8 @@ class UiRequest:
|
||||||
def render(self, template_path, *args, **kwargs):
|
def render(self, template_path, *args, **kwargs):
|
||||||
#template = SimpleTemplate(open(template_path), lookup=[os.path.dirname(template_path)])
|
#template = SimpleTemplate(open(template_path), lookup=[os.path.dirname(template_path)])
|
||||||
#yield str(template.render(*args, **kwargs).encode("utf8"))
|
#yield str(template.render(*args, **kwargs).encode("utf8"))
|
||||||
ENCODING = 'utf-8'
|
template = open(template_path).read().decode("utf8")
|
||||||
template = unicode(open(template_path).read(), ENCODING)
|
yield template.format(**kwargs).encode("utf8")
|
||||||
yield template.format(**kwargs).encode(ENCODING)
|
|
||||||
|
|
||||||
|
|
||||||
# - Actions -
|
# - Actions -
|
||||||
|
|
Loading…
Reference in a new issue