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

Side by Side Diff: cms/converters.py

Issue 29328184: Issue 3092 - Support use of Jinja2 template inheritance (Closed)
Patch Set: Created Sept. 18, 2015, 11:06 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 | « README.md ('k') | cms/utils.py » ('j') | 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 self.include_start_regex, 263 self.include_start_regex,
264 self.include_end_regex 264 self.include_end_regex
265 ), 265 ),
266 resolve_include, 266 resolve_include,
267 text 267 text
268 ) 268 )
269 269
270 def __call__(self): 270 def __call__(self):
271 result = self.get_html(*self._params[self._key]) 271 result = self.get_html(*self._params[self._key])
272 result = self.resolve_includes(result) 272 result = self.resolve_includes(result)
273 if self._key == "pagedata": 273 if self._key == "pagedata" and not self._params["jinja2_inheritence"]:
Wladimir Palant 2015/09/18 13:44:54 Nit: it's inheritance, not inheritence
274 head = [] 274 head = []
275 def add_to_head(match): 275 def add_to_head(match):
276 head.append(match.group(1)) 276 head.append(match.group(1))
277 return "" 277 return ""
278 body = re.sub(r"<head>(.*?)</head>", add_to_head, result, flags=re.S) 278 body = re.sub(r"<head>(.*?)</head>", add_to_head, result, flags=re.S)
279 return "".join(head), body 279 return "".join(head), body
280 else: 280 else:
281 return result 281 return result
282 282
283 class RawConverter(Converter): 283 class RawConverter(Converter):
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 stack.pop() 437 stack.pop()
438 stack[-1]["subitems"].append(item) 438 stack[-1]["subitems"].append(item)
439 stack.append(item) 439 stack.append(item)
440 return structured 440 return structured
441 441
442 converters = { 442 converters = {
443 "html": RawConverter, 443 "html": RawConverter,
444 "md": MarkdownConverter, 444 "md": MarkdownConverter,
445 "tmpl": TemplateConverter, 445 "tmpl": TemplateConverter,
446 } 446 }
OLDNEW
« no previous file with comments | « README.md ('k') | cms/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld