Multitenancy.HTML (multitenancy_phoenix v0.1.0)

Copy Markdown View Source

Embeds a theme's templates, falling back to the base application ones.

defmodule Themes.Alpha.PageHTML do
  use Themes.Alpha, :html

  embed_theme_templates "page_html/*", base: MyAppWeb.PageHTML
end

Every template found in page_html/ next to this file is compiled. Any template of MyAppWeb.PageHTML (looked up with the same pattern next to the base module source) that the theme does not override is compiled too, inside the theme module. A fallback template therefore resolves <Layouts.app>, ~p, imported components and gettext through the theme, the same way Rails renders a fallback view within the theme layout.

Function components defined directly in the base module are not copied; share them through an imported components module instead.

Options

  • :base - the base HTML module (required)
  • :root - directory of the theme templates, defaults to the caller dir
  • :base_root - directory of the base templates, defaults to the base module source dir
  • :base_pattern - pattern for base templates, defaults to pattern

Summary

Functions

embed_theme_templates(pattern, opts)

(macro)