Helpers

Helpers are pre-packaged Rust functions that you can call within your HTMLbars expressions.

In the Ember ecosystem, certain helper packages became popular and are commonly used by many apps. These are made available to Auric webapps. The ones you don't use should be stripped out by the Rust compiler.

How They Work

Helpers streamline your development experience by helping to keep your templates clean, highly readable, and maintainable.

Consider this HTMLbars template:

{{!-- src/templates/customer.hbs --}}
<h2>Customer</h2>

<li>Name: {{titleize (trim this.model.name)}}</li>
<li>Address: {{trim this.model.address}}</li>

When you build your Auric project, let's look at the Leptos view that is generated for you, and some of its complexities that you won't have to face directly:

$ make
$ cat src/generated/views/customer.rs
// This file is @generated by auric-build.

use auric_runtime::{*, components::*, data::*, routing::*};
use leptos::prelude::*;
use leptos_router::{path, components::*};

#[component]
pub fn CustomerView() -> impl IntoView {
    let maybe_model = LocalResource::new(async move || {
        let router = use_context::<Arc<Router>>().expect("Router not found");
        let params = move || use_params_map().get();
        router.set_params_for("customer", params().into());
        router.model_for("customer").await
    });
    let model = Signal::derive(move || maybe_model.get().and_then(Result::ok));
    let model_error = move || maybe_model.get().map(|result| result.map(|_| ()));
    let signal0 = move || model.get().map(|model| model.get("name")).unwrap_or_default();
    let signal1 = move || auric_runtime::helpers::string::trim(&signal0());
    let signal2 = move || auric_runtime::helpers::string::titleize(&signal1());
    let signal3 = move || -> String { signal2().into() };
    let signal4 = move || model.get().map(|model| model.get("address")).unwrap_or_default();
    let signal5 = move || auric_runtime::helpers::string::trim(&signal4());
    let signal6 = move || -> String { signal5().into() };

    view! {
        <h2>"Customer"</h2>
        <li>"Name: " {move || signal3()} </li>
        <li>"Address: " {move || signal6()} </li>
    }
}

ember-cli-string-helpers

The following ember-cli-string-helpers are supported:

camelize, capitalize, classify, dasherize, humanize, lowercase, titleize, trim, truncate, underscore, uppercase, and w.

ember-math-helpers

The following ember-math-helpers are supported:

abs, acos, acosh, add, asin, asinh, atan, atan2, atanh, cbrt, ceil, clz32, cos, cosh, div, exp, expm1, floor, fround, gcd, hypot, imul, lcm, log-e, log1p, log2, log10, max, min, mod, mult, pow, random, round, sign, sin, sqrt, sub, sum, tan, tanh, and trunc.

ember-truth-helpers

The following ember-truth-helpers are supported:

HelperRust OperationHTMLbars Usage
andif (a && b){{if (and a b)}}
eqif (a == b){{if (eq a b)}}
gtif (a > b){{if (gt a b)}}
gteif (a >= b){{if (gte a b)}}
is-arrayif (serde_json::Value::is_array()){{if (is-array a)}}
is-empty...lengthy type-specific logic...{{if (is-empty a)}}
is-equal(identical to eq){{if (is-equal a b)}}
ltif (a < b){{if (lt a b)}}
lteif (a <= b){{if (lte a b)}}
notif (!a){{if (not a)}}
not-eqif (a != b){{if (not-eq a b)}}
orif (a || b){{if (or a b)}}
xorif (a ^ b){{if (xor a b)}}

©2026 Megalithic LLC | Website | Blog | GitLab | Contact