A fork of hyde, the static site generation. Some patches will be pushed upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # pylint: disable-msg=W0104,E0602,W0613,R0201
  3. """
  4. Abstract classes and utilities for template engines
  5. """
  6. class Template(object):
  7. """
  8. Interface for hyde template engines. To use a different template engine,
  9. the following interface must be implemented.
  10. """
  11. def __init__(self, sitepath):
  12. self.sitepath = sitepath
  13. def configure(self, config):
  14. """
  15. The config object is a simple YAML object with required settings. The
  16. template implementations are responsible for transforming this object
  17. to match the `settings` required for the template engines.
  18. """
  19. abstract
  20. def render(self, text, context):
  21. """
  22. Given the text, and the context, this function must return the
  23. rendered string.
  24. """
  25. abstract
  26. @staticmethod
  27. def find_template(site):
  28. """
  29. Reads the configuration to find the appropriate template.
  30. """
  31. # TODO: Find the appropriate template environment
  32. from hyde.ext.templates.jinja import Jinja2Template
  33. template = Jinja2Template(site.sitepath)
  34. return template