Rendering HTMLΒΆ

HTML is just another output format supported by supercell. The default implementation is using tornado’s built in template mechanism for rendering HTML. A RequestHandler supporting HTML only has to implement the get_template() method, that will return the template file name based on the final model. By setting the template_path configuration variable one may define the directory containing all templates.

A minimum example would look like this:

@s.provides(s.MediaType.TextHtml, default=True)
class SimpleHtml(s.RequestHandler):

    def get_template(self, model):
        return 'simple.html'

    def get(self, *args, **kwargs):
        raise s.Return(Saying({'id': self.counter, 'content': content}))

class MyService(s.Service):

    def bootstrap(self):
        self.environment.tornado_settings['template_path'] = 'templates/'

    def run(self):
        self.environment.add_handler('/', SimpleHtml)
Read the Docs v: latest
Versions
latest
v0.4.0
v0.3.0
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.