module-nginx/templates/conf.d/map.erb

16 lines
381 B
Text
Raw Normal View History

2014-06-12 20:12:24 +02:00
map <%= @string %> $<%= @name %> {
<% if @hostnames -%>
hostnames;
<% end -%>
<% if @default -%>
default <%= @default %>;
<% end -%>
2014-06-12 20:12:24 +02:00
<% if @mappings -%>
<%- field_width = @mappings.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
2014-06-12 20:12:24 +02:00
<%- @mappings.sort_by{|k,v| k}.each do |key,value| -%>
<%= sprintf("%-*s", field_width, key) %> <%= value %>;
2014-06-12 20:12:24 +02:00
<%- end -%>
<% end -%>
}