Created
March 24, 2021 05:38
-
-
Save mostlylikeable/137d9f1be39e1967a8397bc27caa512f to your computer and use it in GitHub Desktop.
Go Template Randomness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Comment | |
`{{/* TODO: add more useful things */}}` | |
// Ternary var def with or | |
// $somevar := (.x ? .x : "") | |
`{{ $somevar := or .x "" }}` | |
// Ternary var def with and | |
// $somevar := (.x ? "" : .x) | |
`{{ $somevar := and .x "" }}` | |
// Chaining to concat str | |
// $somevar := (.x ? "has_" + .x : "" | |
`{{ $somevar := print (and .x "has_") (or .x "") }}` | |
// Access var from parent scope | |
`{{ $.x }}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment