Iterate over and print all fields and values using TICK script string templating



Published: 2021-08-13 11:22:46 +0000
Categories: TICK Scripts,

Language

TICK Scripts

Description

This snippet uses the string template's range function to iterate over either .Fields or .Tags printing both key and value

Similar to

Snippet

# Fields
var s = '{{ range $k, $v := .Fields}} {{$k}}={{$}} | {{end}}'

# Tags
var t = '{{ range $k, $v := .Tags}} {{$k}}={{$}} | {{end}}'

Keywords

string template, tick, iterate, print_r,

Latest Posts


Copyright © 2021 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk and http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion