Commit ade8558d by Timothée Peignier

ahem

parent 6baaa5bb
......@@ -91,7 +91,7 @@ class Compressor(object):
base_path = self.base_path(paths)
for path in paths:
contents = self.read_file(path)
contents = re.sub(r"\r?\n", "\\n", contents)
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" % (
......
......@@ -71,12 +71,12 @@ class CompressorTest(TestCase):
def test_compile_templates(self):
templates = self.compressor.compile_templates(['templates/photo/list.jst'])
self.assertEquals(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'list\'] = template(\'<div class="photo">\n <img src="<%%= src %%>" />\n <div class="caption">\n <%%= caption %%>\n </div>\n</div>\');\n""" % TEMPLATE_FUNC)
self.assertEquals(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'list\'] = template(\'<div class="photo">\\n <img src="<%%= src %%>" />\\n <div class="caption">\\n <%%= caption %%>\\n </div>\\n</div>\');\n""" % TEMPLATE_FUNC)
templates = self.compressor.compile_templates([
'templates/video/detail.jst',
'templates/photo/detail.jst'
])
self.assertEqual(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'video_detail\'] = template(\'<div class="video">\n <video src="<%%= src %%>" />\n <div class="caption">\n <%%= description %%>\n </div>\n</div>\');\nwindow.JST[\'photo_detail\'] = template(\'<div class="photo">\n <img src="<%%= src %%>" />\n <div class="caption">\n <%%= caption %%> by <%%= author %%>\n </div>\n</div>\');\n""" % TEMPLATE_FUNC)
self.assertEqual(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'video_detail\'] = template(\'<div class="video">\\n <video src="<%%= src %%>" />\\n <div class="caption">\\n <%%= description %%>\\n </div>\\n</div>\');\nwindow.JST[\'photo_detail\'] = template(\'<div class="photo">\\n <img src="<%%= src %%>" />\\n <div class="caption">\\n <%%= caption %%> by <%%= author %%>\\n </div>\\n</div>\');\n""" % TEMPLATE_FUNC)
def test_embeddable(self):
self.assertFalse(self.compressor.embeddable('images/sprite.png', None))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment