Skip to content

Instantly share code, notes, and snippets.

@boardstretcher
Created June 3, 2019 19:36
Show Gist options
  • Save boardstretcher/864b9572ac6e0fcf20b6978f3e29d027 to your computer and use it in GitHub Desktop.
Save boardstretcher/864b9572ac6e0fcf20b6978f3e29d027 to your computer and use it in GitHub Desktop.
ruby template testing
require 'erb'
@template_variable = 'hostname.net'
template = ERB.new File.read("/root/checkouts/my_template.erb"), nil, "%"
puts template.result(binding)
## The template file
# .split and .first will split hostname.net into two fields and print the
# first field
# <node name="<%= @template_variable.split(".").first %>">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment