def sourcesLoaded(self, locale, moduleName, modulePath): self.rebuildNeeded = False module = self.currentBuild.files[locale][moduleName] templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".tmpl.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") contents = self.projectBuilder.modifiedFiles.read(locale, path) if contents: module[path] = contents self.rebuildNeeded = True if not self.rebuildNeeded: return print " Loading jQuery templates..." module["__templates__"] = u"" wsReplacer = re.compile(r"[ \t\n\r\f\v]+", flags=re.MULTILINE) spaceReplacer = re.compile(r"> <", flags=re.MULTILINE) templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".tmpl.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") template = None templateId = None for line in module[path].splitlines(): if line.startswith("<!-- template"): try: templateId = re.findall(r"id=\"(.*)\"", line)[0] except IndexError: raise BuildError( "Template is missing an ID in file %s" % os.path.basename(path)) template = u"" elif line.startswith("<!-- /template"): template = template.replace( " href=\"#\"", " href=\"javascript:void(0)\"") template = wsReplacer.sub(r" ", template).strip() template = spaceReplacer.sub(r"><", template) module[ "__templates__"] += u"$.template(\"%s.%s\", '%s');\n" % ( moduleName, templateId, buildutil.jsStringEscape(template)) template = None else: if template is not None: template += line
def sourcesLoaded(self, locale, moduleName, modulePath): self.rebuildNeeded = False module = self.currentBuild.files[locale][moduleName] templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".moustache.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") contents = self.projectBuilder.modifiedFiles.read(locale, path) if contents: module[path] = contents self.rebuildNeeded = True if not self.rebuildNeeded: return print " Loading Hogan templates..." module["__templates__"] = u"Modules.%s.templates={};" % moduleName templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".moustache.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") template = None templateId = None for line in module[path].splitlines(): if line.startswith("<!-- template"): try: templateId = re.findall(r"id=\"(.*)\"", line)[0] except IndexError: raise BuildError("Template is missing an ID in file %s" % os.path.basename(path)) template = u"" elif line.startswith("<!-- /template"): template = template.replace(" href=\"#\"", " href=\"javascript:void(0)\"") pipes = subprocess.Popen(self.shermanDir + "/features/hogan/precompile.js", shell = True, stdin = subprocess.PIPE, stdout = subprocess.PIPE) compiledTemplate = "" while pipes.poll() == None: (stdoutdata, stderrdata) = pipes.communicate(input = template) if stderrdata != None or pipes.returncode != 0: raise BuildError("Error compiling Moustache template %s: %s" % (os.path.basename(path), stderrdata)) compiledTemplate += stdoutdata module["__templates__"] += "Modules.%s.templates[\"%s\"] = new Hogan.Template(%s);\n" % (moduleName, templateId, compiledTemplate) template = None else: if template is not None: template += line
def sourcesLoaded(self, locale, moduleName, modulePath): self.rebuildNeeded = False module = self.currentBuild.files[locale][moduleName] templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".tmpl.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") contents = self.projectBuilder.modifiedFiles.read(locale, path) if contents: module[path] = contents self.rebuildNeeded = True if not self.rebuildNeeded: return print " Loading jQuery templates..." module["__templates__"] = u"" wsReplacer = re.compile(r"[ \t\n\r\f\v]+", flags = re.MULTILINE) spaceReplacer = re.compile(r"> <", flags = re.MULTILINE) templates = buildutil.dirEntries(modulePath + "/tmpl") for path in templates: if not path.endswith(".tmpl.html"): continue path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl") template = None templateId = None for line in module[path].splitlines(): if line.startswith("<!-- template"): try: templateId = re.findall(r"id=\"(.*)\"", line)[0] except IndexError: raise BuildError("Template is missing an ID in file %s" % os.path.basename(path)) template = u"" elif line.startswith("<!-- /template"): template = template.replace(" href=\"#\"", " href=\"javascript:void(0)\"") template = wsReplacer.sub(r" ", template).strip() template = spaceReplacer.sub(r"><", template) module["__templates__"] += u"$.template(\"%s.%s\", '%s');\n" % (moduleName, templateId, buildutil.jsStringEscape(template)) template = None else: if template is not None: template += line