laravel-template-engine 0.5.0

Templates for emails, documents and notifications that your team edits, stored in the database
Documentation
//! The package's settings.

use laravel::config::Section;

/// The package's settings, read from the environment. Every one has a default, so nothing needs
/// to be set. An application changes them in `with_config`:
///
/// ```no_run
/// # use laravel::Application;
/// use laravel_template_engine::TemplateEngineConfig;
///
/// # let _ =
/// Application::configure().with_config(|config, _| {
///     config.section_mut::<TemplateEngineConfig>().locale = "uk".into();
/// })
/// # ;
/// ```
#[derive(Debug, Clone, Section)]
pub struct TemplateEngineConfig {
    /// The language used when a recipient's language has no text in the template.
    #[env("TEMPLATE_ENGINE_LOCALE", default = "en".to_owned())]
    pub locale: String,
    /// The currency `| money` uses when a template doesn't name one.
    #[env("TEMPLATE_ENGINE_CURRENCY", default = "USD".to_owned())]
    pub currency: String,
    /// The queue connection messages go through. Empty means the application's default.
    #[env("TEMPLATE_ENGINE_QUEUE_CONNECTION")]
    pub queue_connection: Option<String>,
    /// The queue messages go on. Empty means the connection's default.
    #[env("TEMPLATE_ENGINE_QUEUE")]
    pub queue: Option<String>,
    /// How much work one render may do: roughly the number of steps, loop iterations included.
    #[env("TEMPLATE_ENGINE_FUEL", default = 2_000_000)]
    pub fuel: u64,
    /// The most bytes one render may write.
    #[env("TEMPLATE_ENGINE_MAX_OUTPUT", default = 2 * 1024 * 1024)]
    pub max_output: usize,
    /// The longest one render may take, in milliseconds.
    #[env("TEMPLATE_ENGINE_TIMEOUT_MS", default = 2_000)]
    pub timeout_ms: u64,
    /// How deeply `if` and `for` blocks may nest.
    #[env("TEMPLATE_ENGINE_MAX_DEPTH", default = 10)]
    pub max_depth: usize,
    /// The most characters a template's text may have.
    #[env("TEMPLATE_ENGINE_MAX_LENGTH", default = 200_000)]
    pub max_length: usize,
    /// What a test send puts in front of the subject.
    #[env("TEMPLATE_ENGINE_TEST_PREFIX", default = "[Test] ".to_owned())]
    pub test_prefix: String,
}

pub(crate) fn config() -> TemplateEngineConfig {
    laravel::config().section::<TemplateEngineConfig>().clone()
}