Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
hostclass :class do
  items = scope.lookupvar('items_list')
  items.each do |item|
    file("/etc/init.d/#{item}",
         :content => template(['class/item_init.erb']))
  end
end

Having this class written in Ruby DSL, how do I properly reference the item variable in the template? I tried <%= item %>, <%= @item %>, <%= scope.lookupvar('item')%> but none of them work - they all return nil.

UPD

I've found out that it works if inside the loop I define $item_name = item and then reference it as $item_name in the template.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've found out that it works if inside the loop I define $item_name = item and then reference it as $item_name in the template.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.