ruby - Reference middleman config property dynamically based on current page -


i have json data file in middleman project has object info 5 sections of a site building prototypes new project. here part of file:

"industries": {   "insulation": {     "url": "insulation",     "color": "#b48126"   },   "roofing": {     "url": "roofing",     "color": "#52bd4a"   }, ... 

i'd pull attributes object based on current page.

for instance, if i'm on page in insulation section, i'd grab highlight color insulation file , use part of prototype, can try different colors client.

at top of each .erb template, put page data variable denote industry:

;;; "product": "commerical insulation", "division": "insulation" ;;; 

and further down template, use things this:

  <img  class="img-responsive center-block"          src="<%= lorem.image('1140x100',                :text => current_page.data.product + ' image',                :color => data.lists.industries.{current_page.data.division}.color) %>" /> 

i know {current_page.data.division} not right (throws syntax error, unexpected tlbrace).

i'm new ruby , erb, if there better way approach this, i'm open suggestions.

did try data.lists.industries[current_page.data.division].color?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -