Passing variables into a javascript erb file



I’m hoping someone could please assist with this problem.

I’ve got a scenario where I use these dynamic variables within a template .dashboard.js.erb file (using it to construct a grafana dashboard):


/* global _ */

‘use strict’;

var windows, document, $, jQuery, moment, kbn, ARGS;

var dashboard;

var rows = 5;

var env = :metric;

var nodes_env = :node;…

and my recipe uses the following resource:-


dashboard_path = “/usr/share/public/grafana”

file = “dashboard.js”

metric = “blue-monolith”

node = “nodes.production_blue”

template File.join(dashboard_path, file) do

source “dashboard.js.erb”


       :metric => metric,

       :node => node




Does anyone know how to represent these dynamic variables (:metric and :node) in a .js.erb file?

Many thanks

Sent from iCloud


<%= @metric %>

Mark Keisler