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 from third_party.handlebar import Handlebar | 5 from third_party.handlebar import Handlebar |
6 | 6 |
7 EXTENSIONS_URL = '/chrome/extensions' | 7 EXTENSIONS_URL = '/chrome/extensions' |
8 | 8 |
9 class TemplateDataSource(object): | 9 class TemplateDataSource(object): |
10 """This class fetches and compiles templates using the fetcher passed in with | 10 """This class fetches and compiles templates using the fetcher passed in with |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 'partials': self, | 46 'partials': self, |
47 }).text | 47 }).text |
48 | 48 |
49 def __getitem__(self, key): | 49 def __getitem__(self, key): |
50 return self.get(key) | 50 return self.get(key) |
51 | 51 |
52 def get(self, key): | 52 def get(self, key): |
53 index = key.rfind('.html') | 53 index = key.rfind('.html') |
54 if index > 0: | 54 if index > 0: |
55 key = key[:index] | 55 key = key[:index] |
56 real_path = key + '.html' | 56 safe_key = key.replace('.', '_') |
| 57 real_path = safe_key + '.html' |
57 for base_path in self._base_paths: | 58 for base_path in self._base_paths: |
58 try: | 59 try: |
59 return self._cache.get(base_path + '/' + real_path) | 60 return self._cache.get(base_path + '/' + real_path) |
60 except: | 61 except: |
61 pass | 62 pass |
62 return None | 63 return None |
OLD | NEW |