The Templating API
If you're using Kerbi, you probably enjoy Ruby in YAML, a.k.a ERB. This guide covers the most useful methods available to you inside your .yaml.erb
files.
Most of the methods here come from Kerbi::Mixins::Mixer
, which is documented here.
Public and Custom Mixer API methods
In addition to the methods listed in the next sections, you have access to:
Every public method from the Mixer API (e.g
values
,file()
, etc...), except#push()
Any custom methods you define in your Mixer subclass, including those included from modules
See both in action below with file()
and ingress_enabled?()
:
The b64enc()
method
b64enc()
methodEncodes a string as its Base64 representation, as it is often necessary with Secrets:
The b64dec()
method
b64dec()
methodDecodes a string from its Base64 representation:
The embed()
and embed_array()
methods
embed()
and embed_array()
methodsThe embed()
and embed_array()
methods convert, respectively, a Hash
and an Array<Hash>
, into an appropriately indented String
that can be embedded into a YAML file.
About Indentation
Both methods assume that what you're trying to embed should appear as far "right" as possible. If this is not what you need, you can pass the optional indent: Integer
option. If the indent is wrong, e.g it is too small, YAML parsing will raise an exception and templating will fail.
Embedding items into a List
If you have a YAML-defined list and need to add individual items, the best known way to do this (although this is not ideal), is to call embed_array()
with an explicit indent: Integer
that you find by counting, or more realistically by trial and error.
Last updated