if_os

Function if_os 

Source
pub fn if_os<'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 conditions on values parsed from target machine’s /etc/os-release file. The querying keys are case agnostic.

Usage:

  1. {{#if_os "PRETTY_NAME" "foo,bar"}}..baz..{{/if_os}}

    Renders ..baz.. only if current machine’s PRETTY_NAME is either “foo” or “bar”

  2. {{#if_os "id" "foo"}}..baz..{{else}}..qux..{{/if_os}}

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

  3. {{#if_os "build_id" some.array}}..foo..{{/if_os}}

    Renders ..foo.. only if current machine’s BUILD_ID 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