Skip to content

Instantly share code, notes, and snippets.

@WhatsARanjit
Created October 31, 2017 13:43
Show Gist options
  • Save WhatsARanjit/3886664938245f3d99a70b7ac5fdeaf7 to your computer and use it in GitHub Desktop.
Save WhatsARanjit/3886664938245f3d99a70b7ac5fdeaf7 to your computer and use it in GitHub Desktop.
ERB to EPP
[root@node ~]# ./pepper.rb template.erb
<%- | String $str_foo,
Array $list,
Hash $dict,
Array $list_2,
Hash $list_3,
| -%>
My IP is <%= $str_foo %>.
<% $list.each |$val| { -%>
Value: <%= $val %>
<% } -%>
<% $dict.each |$k,$v| { -%>
<%= $k %>: <%= $v %>
<% } -%>
The first value is <%= $list_2[0] %>.
The 'last' value is <%= $list_3['last'] %>.
My IP is <%= @str_foo %>.
<% @list.each do |val| -%>
Value: <%= val %>
<% end -%>
<% @dict.each do |k,v| -%>
<%= k %>: <%= v %>
<% end -%>
The first value is <%= @list_2[0] %>.
The 'last' value is <%= @list_3['last'] %>.
@WhatsARanjit
Copy link
Author

Alternate ending?

[root@node ~]# ./pepper.rb template.erb
New template at 'template.epp'.
Below is an example usage after moving template in your module:

epp("${module_name}/template.epp", {
  'str_foo' => 'foo',
  'list' => ['foo', 'bar'],
  'dict' => { 'foo' => 'bar' },
  'list_2' => ['foo', 'bar'],
  'list_3' => { 'foo' => 'bar' }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment