Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/common/extensions/docs/server2/template_data_source.py

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments - Patch currently being broken up Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from branch_utility import BranchUtility 7 from branch_utility import BranchUtility
8 from docs_server_utils import FormatKey 8 from docs_server_utils import FormatKey
9 from file_system import FileNotFoundError 9 from file_system import FileNotFoundError
10 from third_party.handlebar import Handlebar 10 from third_party.handlebar import Handlebar
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 self._public_template_path = public_template_path 112 self._public_template_path = public_template_path
113 self._private_template_path = private_template_path 113 self._private_template_path = private_template_path
114 self._static_resources = static_resources 114 self._static_resources = static_resources
115 115
116 def Render(self, template_name): 116 def Render(self, template_name):
117 """This method will render a template named |template_name|, fetching all 117 """This method will render a template named |template_name|, fetching all
118 the partial templates needed from |self._cache|. Partials are retrieved 118 the partial templates needed from |self._cache|. Partials are retrieved
119 from the TemplateDataSource with the |get| method. 119 from the TemplateDataSource with the |get| method.
120 """ 120 """
121 template = self.GetTemplate(self._public_template_path, template_name) 121 template = self.GetTemplate(self._public_template_path, template_name)
122 if not template: 122 if template is None:
123 return None 123 return None
124 # TODO error handling 124 # TODO error handling
125 render_data = template.render({ 125 render_data = template.render({
126 'api_list': self._api_list_data_source, 126 'api_list': self._api_list_data_source,
127 'apis': self._api_data_source, 127 'apis': self._api_data_source,
128 'branchInfo': self._branch_info, 128 'branchInfo': self._branch_info,
129 'intros': self._intro_data_source, 129 'intros': self._intro_data_source,
130 'sidenavs': self._sidenav_data_source, 130 'sidenavs': self._sidenav_data_source,
131 'partials': self, 131 'partials': self,
132 'samples': self._samples_data_source, 132 'samples': self._samples_data_source,
(...skipping 16 matching lines...) Expand all
149 149
150 def get(self, key): 150 def get(self, key):
151 return self.GetTemplate(self._private_template_path, key) 151 return self.GetTemplate(self._private_template_path, key)
152 152
153 def GetTemplate(self, base_path, template_name): 153 def GetTemplate(self, base_path, template_name):
154 try: 154 try:
155 return self._cache.GetFromFile( 155 return self._cache.GetFromFile(
156 '/'.join((base_path, FormatKey(template_name)))) 156 '/'.join((base_path, FormatKey(template_name))))
157 except FileNotFoundError as e: 157 except FileNotFoundError as e:
158 return None 158 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698