Commit b7c896a4 authored by j.knedlik's avatar j.knedlik
Browse files

Merge branch 'render_array' into HEAD

parents 20d141de c98131f2
......@@ -44,6 +44,22 @@ resource_list = %w(
route
mount
)
# func(value,node-object) recursively render Arrays and Strings using ERB
module BaseTemplateERB
def self.render_erbs(value,node)
case value
when Array
value=value.collect{|v| render_erbs(v,node) }
when String
value=ERB.new(value,nil,'-').result_with_hash(node:node)
else
value
end
end
end
if not node['base']['resources'].empty?
resource_list += node['base']['resources']
......@@ -85,14 +101,14 @@ resource_list.each do |resource|
# Expand user defined 'name' of resource via ERB if specified
expanded_name = template_fields.include?("name") ?
ERB.new(name,nil,'-').result_with_hash(node:node) :
BaseTemplateERB::render_erbs(name,node) :
name
public_send(resource, expanded_name) do
conf.each do |key,value|
# Expand config field via ERB if specified
value=ERB.new(value,nil,'-').result_with_hash(node:node) if template_fields.include?key
value=BaseTemplateERB::render_erbs(value,node) if template_fields.include?key
case key
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment