OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 data_source_registry import CreateDataSources | 5 from data_source_registry import CreateDataSources |
6 from third_party.handlebar import Handlebar | 6 from third_party.handlebar import Handlebar |
7 from url_constants import GITHUB_BASE, EXTENSIONS_SAMPLES | 7 from url_constants import GITHUB_BASE, EXTENSIONS_SAMPLES |
8 | 8 |
9 | 9 |
10 class TemplateRenderer(object): | 10 class TemplateRenderer(object): |
(...skipping 18 matching lines...) Expand all Loading... | |
29 ''' | 29 ''' |
30 assert isinstance(template, Handlebar), type(template) | 30 assert isinstance(template, Handlebar), type(template) |
31 render_context = self._CreateDataSources(request) | 31 render_context = self._CreateDataSources(request) |
32 if data_sources is not None: | 32 if data_sources is not None: |
33 render_context = dict((name, d) for name, d in render_context.iteritems() | 33 render_context = dict((name, d) for name, d in render_context.iteritems() |
34 if name in data_sources) | 34 if name in data_sources) |
35 render_context.update({ | 35 render_context.update({ |
36 'apps_samples_url': GITHUB_BASE, | 36 'apps_samples_url': GITHUB_BASE, |
37 'base_path': self._server_instance.base_path, | 37 'base_path': self._server_instance.base_path, |
38 'extensions_samples_url': EXTENSIONS_SAMPLES, | 38 'extensions_samples_url': EXTENSIONS_SAMPLES, |
39 # TODO(kalman): Figure out where "pepperversion" comes from. It's used | |
40 # internally in pepper and unfortunately the syntax appears to be | |
41 # {{pepperversion}} for some reason. | |
42 'pepperversion': '', | |
binji
2014/06/20 23:24:07
This used to be in the pepper API docs, but I don'
| |
43 'static': self._server_instance.base_path + 'static', | 39 'static': self._server_instance.base_path + 'static', |
44 }) | 40 }) |
45 if additional_context: | 41 if additional_context: |
46 render_context.update(additional_context) | 42 render_context.update(additional_context) |
47 render_data = template.Render(render_context) | 43 render_data = template.Render(render_context) |
48 return render_data.text, render_data.errors | 44 return render_data.text, render_data.errors |
49 | 45 |
50 def _CreateDataSources(self, request): | 46 def _CreateDataSources(self, request): |
51 server_instance = self._server_instance | 47 server_instance = self._server_instance |
52 data_sources = CreateDataSources(server_instance, request=request) | 48 data_sources = CreateDataSources(server_instance, request=request) |
53 data_sources.update({ | 49 data_sources.update({ |
54 'samples': server_instance.samples_data_source_factory.Create(request), | 50 'samples': server_instance.samples_data_source_factory.Create(request), |
55 }) | 51 }) |
56 return data_sources | 52 return data_sources |
OLD | NEW |