if_user

Function if_user 

Source
pub fn if_user<'reg, 'rc>(
    h: &Helper<'reg, 'rc>,
    r: &'reg Handlebars<'reg>,
    ctx: &'rc Context,
    rc: &mut RenderContext<'reg, 'rc>,
    out: &mut dyn Output,
) -> HelperResult
Expand description

A templating helper that tests if current user’s username matches a set of given string(s).

Usage:

  1. {{#if_user "foo,bar"}}..baz..{{/if_user}}

    Renders ..baz.. only if current user’s username is either “foo” or “bar”.

  2. {{#if_user "foo"}}..baz..{{else}}..qux..{{/if_user}}

    Renders ..baz.. only if current user’s username is “foo”, renders ..qux.. only if current user’s username is NOT “foo”.

  3. {{#if_user some.array}}..foo..{{/if_user}}

    Renders ..foo.. only if current user’s username is exactly one of the values from the templating variable some.array (defined in the config file’s [[context]] section).

[[context]]: dt_core::config::ContextConfig