View Source Templates for Dynamic HTML

Note: This page is being updated for OSS release. Please be patient.

  • Gears can use HAML templates to render dynamic HTML.
  • We are using calliope as the HAML engine. Please refer to calliope's documentation for its syntax.
  • To use HAML:
    • Confirm that web/template.ex is present (it's automatically generated by the gear generator).
    • Place your HAML files under web/template/.
    • HAML templates are processed during $ mix compile and content of each file is packed into a clause of YourGear.Template.content_for/2.
    • Render HTML responses by using render/5 function in your controller action.
  • HTML-escaping in HAML templates
    • Dynamic parts in HAML templates are automatically HTML-escaped (i.e. special characters are replaced with character entity references).
    • If you want to insert elements without escaping, use Antikythera.TemplateSanitizer.raw/1. Antikythera.TemplateSanitizer is automatically imported and thus you can just write e.g. = raw "<this won't be escaped>" in your HAML templates.
  • Inserting other templates in a template (a.k.a. partial rendering)
    • You can simply call content_for/2 (without YourGear.Template. prefix) from within your HAML templates. e.g. = content_for "path/to/other/template", param1: value1