コード例 #1
0
ファイル: page.py プロジェクト: jbruwer/pygrow
 def render(self):
   # TODO(jeremydw): This is a bit hacky. Be more explicit about translations.
   ll = self.locale
   self._install_translations(ll)
   template = self._template_env.get_template(self.view.lstrip('/'))
   context = {}
   context = {
       'categories': lambda *args, **kwargs: tags.categories(*args, _pod=self.pod, **kwargs),
       'docs': lambda *args, **kwargs: tags.docs(*args, _pod=self.pod, **kwargs),
       'doc': lambda *args, **kwargs: tags.get_doc(*args, _pod=self.pod, **kwargs),
       'static': lambda path: tags.static(path, _pod=self.pod),
       'breadcrumb': lambda *args, **kwargs: tags.breadcrumb(*args, _pod=self.pod, **kwargs),
       'nav': lambda *args, **kwargs: tags.nav(*args, _pod=self.pod, **kwargs),
       'cc': self.cc,
       'll': self.ll,
       'params': self.route_params,
       'pod': self.pod,
       'url': lambda *args, **kwargs: tags.url(*args, _pod=self.pod, **kwargs),
   }
   try:
     return template.render({
         'g': context,
         'doc': self.document,
         'podspec': self.pod.get_podspec(),
     })
   except Exception as e:
     text = 'Error building {}: {}'
     logging.exception(e)
     raise errors.BuildError(text.format(self, e))
コード例 #2
0
ファイル: page.py プロジェクト: statusz/pygrow
 def render(self):
   self._install_translations(self.ll)
   template = self._template_env.get_template(self.view.lstrip('/'))
   context = {
       'cc': self.cc,
       'content': self.document,  # TODO: Remove.
       'doc': self.document,
       'docs': lambda *args, **kwargs: tags.docs(*args, _pod=self.pod, **kwargs),
       'categories': lambda *args, **kwargs: tags.categories(*args, _pod=self.pod, **kwargs),
       'is_active': lambda doc: tags.is_active(doc, self.document),
       'static': lambda path: tags.static(path, _pod=self.pod),
       'll': self.ll,
       'params': self.route_params,
       'pod': self.pod,
   }
   try:
     return template.render({'g': context})
   except Exception as e:
     text = 'Error building {}: {}'
     logging.exception(e)
     raise errors.BuildError(text.format(self, e))