Skip to content

Cookbook: Using Templates

David Souther edited this page Mar 6, 2015 · 4 revisions

Q: How do I make use of templates in Rupert?

Regardless of markup type (e.x.: Jade or HTML), templates are persisted in Rupert's templates.js file. Rupert intelligently stores templates as based off of the template's relative 'feature' directory name via a <dir>/<component name>-template.<ext> format.

Consider the following structure:
  • main/template.jade
  • main/content/content-template.html
  • main/dashboard/panel-template.jade

...the templates are now respectively accessible via:

  • window.Templates['main']
  • window.Templates['main/content']
  • window.Templates['main/dashboard/panel']
Additional Notes:
  • If you're using Rupert's Angular config, please see this cookbook entry regarding templates.
  • Templates must have a known extension in the Template Renderer (Default HTML & Jade, must transpile to HTML, new renderers may be added).
  • Templates may have an arbitrary prefix, separated with a - eg -template..
  • The generated fragment name is The path within the client source folder, as determined by AssetWatcher::pathpart
  • Except the suffix template.<extension> and either the preceding - or / are dropped.
  • If the template file prefix matches the parent directory name, the prefix gets dropped.