Skip to content

wincus/benthos-gotmpl-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gotmpl benthos processor plugin

Gotmpl is a Benthos processor plugin that allows you to use Go templates to render messages.

Why?

Sometimes is easier to express content as a rendered go template.

Installation

go install github.com/wincus/benthos-gotmpl-plugin@latest

Configuration example

input:
  generate:
    mapping: |
      root = {"name":"John", "toys": ["car", "phone", "cards"], "good": true}
    count: 1

pipeline:
  processors:
    - gotmpl:
        template: >
          Hi there {{ .name }}! Your toys are:
          {{ range .toys }}
            - {{ . -}}
          {{ end }}
          {{ if .good }}
          
          You have been a good boy!
          {{ end }}
$ go run main.go -c conf/config.yaml
Hi there John! Your toys are: 
  - car
  - phone
  - cards 
You have been a good boy!