Skip to content

Instantly share code, notes, and snippets.

@hlindberg
Created December 2, 2016 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlindberg/b4aa1694350534f7d991fed912f9c076 to your computer and use it in GitHub Desktop.
Save hlindberg/b4aa1694350534f7d991fed912f9c076 to your computer and use it in GitHub Desktop.
An example of using a local variable in EPP
# Example of local variables set inside of an EPP template
#
$template = @(EOF)
<%
# this is an element with arbitrary puppet code
$hash = { a => 1, b => 2, c => 3 }
-%>
The keys are:
<%- $hash.each |$key, $value| { -%>
<%= $key %>
<%- } -%>
The values are:
<%- $hash.each |$key, $value| { -%>
<%= $value %>
<%- } -%>
So long, and thanks for all the fish.
EOF
notice inline_epp($template)
@hlindberg
Copy link
Author

Outputs:

Notice: Scope(Class[main]):     The keys are:
    a
    b
    c

  The values are:
    1
    2
    3

  So long, and thanks for all the fish.

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