Skip to content

Getting Autotune data into apps

Aidan Feay edited this page Jul 29, 2015 · 5 revisions

So you’ve got an autotune-config.json that allows users to output custom JSON for your blueprint. Now what? Let’s take advantage of all that data.

Middleman supports access via object notation for all files within a data folder at the root of your app. This means that you can reference anything in autotune.json with data.autotune.<property>.

The autotune object is accessible anywhere you could use ruby:

In the DOM...
<h1><%= data.autotune.title %></h1>

In your config.rb
set :vertical, data.autotune.theme

Or elsewhere!

To access your data in javascript, add this to the top of your index.html.erb
<script>var AUTOTUNE = <%= data.autotune.to_json %></script>