Skip to content
AXVI BUILD · WRITE · SHIP
Packages

Laravel Template Engine

Email, document and notification templates for Laravel Rust that your team edits in the database: every language, recipients, PDF documents and a real sandbox.

Laravel Template Engine

Your code declares a template type, such as order.placed, with its data. Everything else lives in the database, and the people who run the business change it without a deploy: the text in every language, the subject and the sender, who gets the email, with copies and hidden copies.

The same engine makes documents, such as invoices and contracts, as HTML or PDF, and attaches them to emails. The package is the backend only: it gives an editor everything it needs, and you draw the editor with whatever your application uses.

Features

  • One derive, no registration: #[derive(TemplateData)] describes a type and its variables
  • Recipients in the database: to, cc and bcc hold recipient variables and plain addresses
  • Every language: each recipient gets the email in their own language, with a fallback
  • Locale-aware filters: money, numbers, dates with month names and plurals
  • A real sandbox: templates see only their type's data, with limits on work, size and time
  • Checks before saving: line and column, unknown variables with "did you mean" hints
  • Emails through the queue, CSS inlined, a plain text version made for you
  • Notification texts for SMS, Slack and any channel a package adds
  • Documents as HTML or PDF, for download or as attachments
  • An editor API: variables as JSON, previews with example data, test sends

Installation

cargo add laravel-template-engine --features pdf

Leave out pdf if you only need emails and HTML documents.

Quick start

#[derive(Serialize, TemplateData)]
#[template(key = "order.placed", description = "A customer placed an order")]
pub struct OrderPlaced {
    pub customer: Recipient,
    pub order: Order,
}

laravel_template_engine::send(OrderPlaced { customer, order }).await?;

Template types, recipients, documents, layouts and the editor API are covered in the README on GitHub.

Esc