Repository: bottlerocket-os/bottlerocket
File: sources/api/schnauzer/src/v2/import/helpers.rs (Rust)

Code before:
            "pause-prefix" => helper!(handlebars_helpers::pause_prefix),
        },

        "network" => hashmap! {
            "localhost_aliases" => helper!(handlebars_helpers::localhost_aliases),
            "etc_hosts_entries" => helper!(handlebars_helpers::etc_hosts_entries),
            "host" => helper!(handlebars_helpers::host),
        },

        "updates" => hashmap! {
            "tuf-prefix" => helper!(handlebars_helpers::tuf_prefix),
            "metadata-prefix" => helper!(handlebars_helpers::metadata_prefix),
        },

        "oci-defaults" => hashmap! {
            "oci_defaults" => helper!(handlebars_helpers::oci_defaults)
        },

        // globally helpful helpers will be included in a null extension called "std"
        "std" => hashmap! {
            "any_enabled" => helper!(handlebars_helpers::any_enabled),
            "base64_decode" => helper!(handlebars_helpers::base64_decode),
            "default" => helper!(handlebars_helpers::default),
            "join_array" => helper!(handlebars_helpers::join_array),
            "join_map" => helper!(handlebars_helpers::join_map),
            "if-not-null" => Box::new(handlebars_helpers::IfNotNullHelper),
            "goarch" => helper!(handlebars_helpers::goarch),
        },
    }
}

/// An interface which abstracts away the registration of handlebars helpers for template rendering.
#[async_trait]
pub trait HelperResolver {
    /// Registers requested helpers from a specific setting extension for a template.
    async fn register_template_helpers<'a>(
        &self,
        template_registry: &mut Handlebars<'a>,
        extension_requirement: &ExtensionRequirement,
    ) -> std::result::Result<(), Box<dyn std::error::Error>>;
}

/// A `HelperResolver` implementation that uses a static map of helpers compiled into `schnauzer`.
#[derive(Debug, Clone, Default)]
pub struct StaticHelperResolver;

#[async_trait]
impl HelperResolver for StaticHelperResolver {
    /// Registers all handlebars helpers requested by a template.
    ///
    /// This currently uses a global list of all available helpers, but will be changed to only use helpers exposed by

Review comment (refactor):
It looks like the naming convention is underscore:

```suggestion
            "if_not_null" => Box::new(handlebars_helpers::IfNotNullHelper),
```

Code after:
            "pause-prefix" => helper!(handlebars_helpers::pause_prefix),
        },

        "network" => hashmap! {
            "localhost_aliases" => helper!(handlebars_helpers::localhost_aliases),
            "etc_hosts_entries" => helper!(handlebars_helpers::etc_hosts_entries),
            "host" => helper!(handlebars_helpers::host),
        },

        "updates" => hashmap! {
            "tuf-prefix" => helper!(handlebars_helpers::tuf_prefix),
            "metadata-prefix" => helper!(handlebars_helpers::metadata_prefix),
        },

        "oci-defaults" => hashmap! {
            "oci_defaults" => helper!(handlebars_helpers::oci_defaults)
        },

        // globally helpful helpers will be included in a null extension called "std"
        // Prefer snake case for helper names (we accidentally created a few with kabob case)
        "std" => hashmap! {
            "any_enabled" => helper!(handlebars_helpers::any_enabled),
            "base64_decode" => helper!(handlebars_helpers::base64_decode),
            "default" => helper!(handlebars_helpers::default),
            "join_array" => helper!(handlebars_helpers::join_array),
            "join_map" => helper!(handlebars_helpers::join_map),
            "if_not_null" => Box::new(handlebars_helpers::IfNotNullHelper),
            "goarch" => helper!(handlebars_helpers::goarch),
        },
    }
}

/// An interface which abstracts away the registration of handlebars helpers for template rendering.
#[async_trait]
pub trait HelperResolver {
    /// Registers requested helpers from a specific setting extension for a template.
    async fn register_template_helpers<'a>(
        &self,
        template_registry: &mut Handlebars<'a>,
        extension_requirement: &ExtensionRequirement,
    ) -> std::result::Result<(), Box<dyn std::error::Error>>;
}

/// A `HelperResolver` implementation that uses a static map of helpers compiled into `schnauzer`.
#[derive(Debug, Clone, Default)]
pub struct StaticHelperResolver;

#[async_trait]
impl HelperResolver for StaticHelperResolver {
    /// Registers all handlebars helpers requested by a template.
    ///