- From: Tensibai <
>
- To: <
>
- Subject: [chef] Re: *** PROBABLY SPAM *** Template Variable as a Hash
- Date: Wed, 21 Aug 2013 14:51:25 +0200
On Wed, 21 Aug 2013 14:34:43 +0300, "Michael L."
<
>
wrote:
>
Greetings !
>
I am trying to pass a Hash as a variable to the Template like this:
>
>
==================================
>
params = {'key1' => 'val1', 'key2' => 'val2'}
>
>
template "/etc/test.conf" do
>
mode 0640
>
variables(
>
:params => params
>
)
>
end
>
==================================
>
>
My Template looks like this:
>
>
==================================
>
..
>
params = <%= @params.each_pair {|k,v| print "#{k}=#{v} "} %>
>
..
>
==================================
>
>
But this doesn't work, giving the errors on the compile time:
>
>
>
==================================
>
..
>
(erubis):84: syntax error, unexpected tIDENTIFIER, expecting ')'
>
(erubis):90: syntax error, unexpected tIDENTIFIER, expecting ')'
>
..
>
==================================
>
>
Please advise.
>
>
Thanks !
<% ruby code -%>
<%= var_to_display %>
Exemple on what you try to accomplish (working for me on an actual
code):
<% @params.each do |key,value| -%>
<%= key %>=<%= value %>
<% end -%>
Or you may try <% @params.each_pair {|k,v| print "#{k}=#{v} "} -%>
but there I've no idea if it will work or not.
Archive powered by MHonArc 2.6.16.