Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a type function to TextRender #206

Open
jrha opened this issue Oct 7, 2022 · 0 comments
Open

Provide a type function to TextRender #206

jrha opened this issue Oct 7, 2022 · 0 comments

Comments

@jrha
Copy link
Member

jrha commented Oct 7, 2022

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 %]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant