Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: cms/converters.py

Issue 4949324312084480: Issue 2323 - Resolve links automatically in templates as well (Closed)
Patch Set: Created April 20, 2015, 11:41 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 self._env = jinja2.Environment(loader=self._SourceLoader(self._params["sourc e"]), autoescape=True) 323 self._env = jinja2.Environment(loader=self._SourceLoader(self._params["sourc e"]), autoescape=True)
324 self._env.filters.update(filters) 324 self._env.filters.update(filters)
325 self._env.globals.update(globals) 325 self._env.globals.update(globals)
326 326
327 def get_html(self, source): 327 def get_html(self, source):
328 template = self._env.from_string(source) 328 template = self._env.from_string(source)
329 module = template.make_module(self._params) 329 module = template.make_module(self._params)
330 for key, value in module.__dict__.iteritems(): 330 for key, value in module.__dict__.iteritems():
331 if not key.startswith("_"): 331 if not key.startswith("_"):
332 self._params[key] = value 332 self._params[key] = value
333 return unicode(module) 333
334 result = unicode(module)
Sebastian Noack 2015/04/20 11:47:38 Nit: I'd rather chain the function calls instead i
Wladimir Palant 2015/04/20 11:50:37 I'd rather keep it this way - the other generators
335 result = self.process_links(result)
336 return result
334 337
335 def translate(self, default, name, comment=None): 338 def translate(self, default, name, comment=None):
336 # Note: We currently ignore the comment, it is only relevant when 339 # Note: We currently ignore the comment, it is only relevant when
337 # generating the master translation. 340 # generating the master translation.
338 localedata = self._params["localedata"] 341 localedata = self._params["localedata"]
339 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes)) 342 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes))
340 343
341 def get_string(self, name, page): 344 def get_string(self, name, page):
342 localedata = self._params["source"].read_locale(self._params["locale"], page ) 345 localedata = self._params["source"].read_locale(self._params["locale"], page )
343 default = localedata[name] 346 default = localedata[name]
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 stack.pop() 382 stack.pop()
380 stack[-1]["subitems"].append(item) 383 stack[-1]["subitems"].append(item)
381 stack.append(item) 384 stack.append(item)
382 return structured 385 return structured
383 386
384 converters = { 387 converters = {
385 "html": RawConverter, 388 "html": RawConverter,
386 "md": MarkdownConverter, 389 "md": MarkdownConverter,
387 "tmpl": TemplateConverter, 390 "tmpl": TemplateConverter,
388 } 391 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld