def Render(self, template, request, data_sources=None, additional_context=None): '''Renders |template| using |request|. Specify |data_sources| to only include the DataSources with the given names when rendering the template. Specify |additional_context| to inject additional template context when rendering the template. ''' assert isinstance(template, Handlebar), type(template) render_context = CreateDataSources(self._server_instance, request) if data_sources is not None: render_context = dict((name, d) for name, d in render_context.iteritems() if name in data_sources) render_context.update({ 'apps_samples_url': GITHUB_BASE, 'base_path': self._server_instance.base_path, 'extensions_samples_url': EXTENSIONS_SAMPLES, 'static': self._server_instance.base_path + 'static', }) render_context.update(additional_context or {}) render_data = template.Render(render_context) return render_data.text, render_data.errors
def Render(self, template, request, data_sources=None, additional_context=None): '''Renders |template| using |request|. Specify |data_sources| to only include the DataSources with the given names when rendering the template. Specify |additional_context| to inject additional template context when rendering the template. ''' assert isinstance(template, Motemplate), type(template) render_context = CreateDataSources(self._server_instance, request) if data_sources is not None: render_context = dict((name, d) for name, d in render_context.iteritems() if name in data_sources) render_context.update({ 'apps_samples_url': GITHUB_BASE, 'base_path': self._server_instance.base_path, 'extensions_samples_url': EXTENSIONS_SAMPLES, 'static': self._server_instance.base_path + 'static', }) render_context.update(additional_context or {}) render_data = template.Render(render_context) return render_data.text, render_data.errors
def _CreateDataSources(self, request): server_instance = self._server_instance data_sources = CreateDataSources(server_instance, request=request) data_sources.update({ 'samples': server_instance.samples_data_source_factory.Create(request), }) return data_sources
def _CreateDataSources(self, request): server_instance = self._server_instance data_sources = CreateDataSources(server_instance, request=request) data_sources.update({ 'samples': server_instance.samples_data_source_factory.Create(request), }) return data_sources