| 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 docs_server_utils import FormatKey | 7 from docs_server_utils import FormatKey |
| 8 from file_system import FileNotFoundError | 8 from file_system import FileNotFoundError |
| 9 import compiled_file_system as compiled_fs | 9 import compiled_file_system as compiled_fs |
| 10 from third_party.handlebar import Handlebar | 10 from third_party.handlebar import Handlebar |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 'apps_title': 'Apps', | 125 'apps_title': 'Apps', |
| 126 'extensions_title': 'Extensions', | 126 'extensions_title': 'Extensions', |
| 127 'true': True, | 127 'true': True, |
| 128 'false': False | 128 'false': False |
| 129 }) | 129 }) |
| 130 if render_data.errors: | 130 if render_data.errors: |
| 131 logging.error('Handlebar error(s) rendering %s:\n%s' % | 131 logging.error('Handlebar error(s) rendering %s:\n%s' % |
| 132 (template_name, ' \n'.join(render_data.errors))) | 132 (template_name, ' \n'.join(render_data.errors))) |
| 133 return render_data.text | 133 return render_data.text |
| 134 | 134 |
| 135 def __getitem__(self, key): | |
| 136 return self.get(key) | |
| 137 | |
| 138 def get(self, key): | 135 def get(self, key): |
| 139 return self.GetTemplate(self._private_template_path, key) | 136 return self.GetTemplate(self._private_template_path, key) |
| 140 | 137 |
| 141 def GetTemplate(self, base_path, template_name): | 138 def GetTemplate(self, base_path, template_name): |
| 142 real_path = FormatKey(template_name) | 139 real_path = FormatKey(template_name) |
| 143 try: | 140 try: |
| 144 return self._cache.GetFromFile(base_path + '/' + real_path) | 141 return self._cache.GetFromFile(base_path + '/' + real_path) |
| 145 except FileNotFoundError as e: | 142 except FileNotFoundError as e: |
| 146 logging.info(e) | 143 logging.info(e) |
| 147 return None | 144 return None |
| OLD | NEW |