Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 path_utils import FormatKey | 7 from path_utils import FormatKey |
| 8 from third_party.handlebar import Handlebar | 8 from third_party.handlebar import Handlebar |
| 9 | 9 |
| 10 EXTENSIONS_URL = '/chrome/extensions' | 10 EXTENSIONS_URL = '/chrome/extensions' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 cache, | 81 cache, |
| 82 public_template_path, | 82 public_template_path, |
| 83 private_template_path, | 83 private_template_path, |
| 84 request): | 84 request): |
| 85 self._branch_info = branch_info | 85 self._branch_info = branch_info |
| 86 self._static_resources = static_resources | 86 self._static_resources = static_resources |
| 87 self._api_data_source = api_data_source | 87 self._api_data_source = api_data_source |
| 88 self._api_list_data_source = api_list_data_source | 88 self._api_list_data_source = api_list_data_source |
| 89 self._intro_data_source = intro_data_source | 89 self._intro_data_source = intro_data_source |
| 90 self._samples_data_source = samples_data_source_factory.Create(request) | 90 self._samples_data_source = samples_data_source_factory.Create(request) |
| 91 samples_key = '' | |
| 92 self._api_data_source.samples = self._samples_data_source.get(samples_key) | |
|
chebert
2012/07/26 20:36:39
I can combine these? Not sure.
cduvall
2012/07/26 22:04:24
I think it might be better to turn api_data_source
chebert
2012/07/26 22:30:52
Done.
| |
| 91 self._cache = cache | 93 self._cache = cache |
| 92 self._public_template_path = public_template_path | 94 self._public_template_path = public_template_path |
| 93 self._private_template_path = private_template_path | 95 self._private_template_path = private_template_path |
| 94 self._request = request | 96 self._request = request |
| 95 | 97 |
| 96 def Render(self, template_name): | 98 def Render(self, template_name): |
| 97 """This method will render a template named |template_name|, fetching all | 99 """This method will render a template named |template_name|, fetching all |
| 98 the partial templates needed from |self._cache|. Partials are retrieved | 100 the partial templates needed from |self._cache|. Partials are retrieved |
| 99 from the TemplateDataSource with the |get| method. | 101 from the TemplateDataSource with the |get| method. |
| 100 """ | 102 """ |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 118 def get(self, key): | 120 def get(self, key): |
| 119 return self.GetTemplate(self._private_template_path, key) | 121 return self.GetTemplate(self._private_template_path, key) |
| 120 | 122 |
| 121 def GetTemplate(self, base_path, template_name): | 123 def GetTemplate(self, base_path, template_name): |
| 122 real_path = FormatKey(template_name) | 124 real_path = FormatKey(template_name) |
| 123 try: | 125 try: |
| 124 return self._cache.GetFromFile(base_path + '/' + real_path) | 126 return self._cache.GetFromFile(base_path + '/' + real_path) |
| 125 except Exception as e: | 127 except Exception as e: |
| 126 logging.warn(e) | 128 logging.warn(e) |
| 127 return None | 129 return None |
| OLD | NEW |