PhoenixKit.Modules.Legal.TemplateGenerator (phoenix_kit v1.7.71)

Copy Markdown View Source

Generates legal page content from EEx templates.

Templates are loaded from:

  1. Parent application's priv/legal_templates/ (for customization)
  2. PhoenixKit's bundled templates in priv/legal_templates/

Template Variables

All templates receive these variables:

  • @company_name - Company name
  • @company_address - Company address
  • @company_country - Company country
  • @company_website - Company website URL
  • @registration_number - Company registration number
  • @vat_number - VAT number
  • @dpo_name - Data Protection Officer name
  • @dpo_email - DPO email
  • @dpo_phone - DPO phone
  • @dpo_address - DPO address
  • @frameworks - List of selected framework IDs
  • @effective_date - Current date in ISO format

Usage

context = %{
  company_name: "Acme Corp",
  company_address: "123 Main St",
  effective_date: "2025-01-15"
}

{:ok, content} = TemplateGenerator.render("privacy_policy.eex", context)

Summary

Functions

Get the full path to a template file.

List all available templates.

Render a template with the given context.

Check if a template exists.

Functions

get_template_path(template_name)

@spec get_template_path(String.t()) :: String.t()

Get the full path to a template file.

Checks parent application first, then falls back to PhoenixKit templates.

list_available_templates()

@spec list_available_templates() :: [String.t()]

List all available templates.

render(template_name, context)

@spec render(String.t(), map()) :: {:ok, String.t()} | {:error, term()}

Render a template with the given context.

Parameters

  • template_name - Template filename (e.g., "privacy_policy.eex")
  • context - Map of variables to pass to the template

Returns

  • {:ok, content} - Rendered content
  • {:error, reason} - Error reason

template_exists?(template_name)

@spec template_exists?(String.t()) :: boolean()

Check if a template exists.