def compile_file(self, infile, outfile, outdated=False, force=False, **kwargs): if not outdated and not force: return str_ = u'(function() {{\n this.JST || (this.JST = {{}});\n this.JST["{0}"] = {1};\n \n}}).call(this); ' content = self.read_file(self._storage_path(infile)) compiled_content = str_.format(self._template_name(infile), eco.compile(content)) self.save_file(self._storage_path(outfile), compiled_content)
def compile_file(self, content, path): p = path.split("/")[::-1] return u'(function() {\n this.JST || (this.JST = {});\n \ this.JST["%s"] = %s;\n \n}).call(this); ' % ( os.path.join(p[3], p[2], p[1], p[0].split(".")[0]), eco.compile(content) )
def test_compile_with_io(): io_ = StringIO("Hello <%= @name %>") assert eco.compile("Hello <%= @name %>") == eco.compile(io_)
def test_compilation_error(): try: eco.compile("<%= foo") except execjs.ProgramError: pass
def test_compile(): assert eco.compile("Hello <%= @name %>")
def compile_file(self, content, path, force=False, outdated=False, **kwargs): if force or outdated: str_ = u'(function() {{\n this.JST || (this.JST = {{}});\n this.JST["{0}"] = {1};\n \n}}).call(this);' compiled_content = str_.format(self._template_name(content), eco.compile(open(content))) self.save_file(path, compiled_content)