Skip to content

Provide a type function to TextRender #206

@jrha

Description

@jrha

As discussed in quattor/configuration-modules-core#1413, we often end up with blocks of TT code along the lines of:

[%-    IF CCM.is_boolean(pair.value) -%]
[%         pair.value ? 'yes' : 'no' %]
[%-    ELSIF CCM.is_list(pair.value) -%]
[%         pair.value.join(' ') %]
[%-    ELSE -%]
[%         pair.value %]
[%-    END %]

These might be tidier if the type could be used with SWITCH:

[%-    SWITCH CCM.type(pair.key) -%]
[%-        CASE 'boolean' -%]
[%             pair.value ? 'yes' : 'no' %]
[%-        CASE 'list' -%]
[%             pair.value.join(' ') %]
[%-        CASE -%]
[%             pair.value %]
[%-    END %]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions