erb

Allows to Generate output files based on ERB templates

Renders an ERB template with :placeholders given as a hash via parameter.
If no :destination is set, it returns the rendered template as string.

erb
Supported platforms ios, android, mac
Author @hjanuschka

1 Example

# Example `erb` template:

# Variable1 <%= var1 %>
# Variable2 <%= var2 %>
# <% for item in var3 %>
#        <%= item %>
# <% end %>

erb(
  template: "1.erb",
  destination: "/tmp/rendered.out",
  placeholders: {
    :var1 => 123,
    :var2 => "string",
    :var3 => ["element1", "element2"]
  }
)

Parameters

Key Description Default
template ERB Template File
destination Destination file
placeholders Placeholders given as a hash {}
trim_mode Trim mode applied to the ERB

* = default value is dependent on the user's system


Documentation

To show the documentation in your terminal, run

fastlane action erb

CLI

It is recommended to add the above action into your Fastfile, however sometimes you might want to run one-offs. To do so, you can run the following command from your terminal

fastlane run erb

To pass parameters, make use of the : symbol, for example

fastlane run erb parameter1:"value1" parameter2:"value2"

It's important to note that the CLI supports primitive types like integers, floats, booleans, and strings. Arrays can be passed as a comma delimited string (e.g. param:"1,2,3"). Hashes are not currently supported.

It is recommended to add all fastlane actions you use to your Fastfile.


Source code

This action, just like the rest of fastlane, is fully open source, view the source code on GitHub


Back to actions