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 mac, linux, windows
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 {}

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


Documentation

To show the documentation in your terminal, run

pantograph action erb

CLI

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

pantograph run erb

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

pantograph 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 pantograph actions you use to your Pantfile.


Source code

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


Back to actions