Chef Recipe, iteration over array of attributes and templates variable

Attribute

default['app_metadata']['metadata'] = {}

Role

"app_metadata": {
  "metadata": {
    "oes_m1": {
      "app.instance": "oes_m1_instance",
      "app.appname": "oes"
      ".."
    },
    "oes_m2": {
      "app.instance": "oes_m2_instance",
      "app.appname": "oes"
      "xx"
      ".."
    }
  }
}

Recipe

node['app_metadata']['metadata'].each do |instance_name, content|

  template "#{node['app_metadata']['home']}/#{node['hostname']}.app.#{instance_name}.metadata" do
    source 'app_metadata.erb'
    owner node['app_metadata']['user']
    group node['app_metadata']['group']
    mode '0755'
    variables(
      content_erb: content
    )
    action :create
  end
end

Template

<% (@content_erb).each do |key, value| -%>
<%= key %>: <%= value %>
<% end -%>

I keep getting errors on the iteration on passing the variables to template. Does anyone know how to improve this?

Expect Result

app.oes_m1.metadata file

app.instance: oes_m1
app.appname: oes
..
app.oes_m2.metadata file

app.instance: oes_m2
app.appname: oes
xx
..
if more instances

key: value
..