I have a deface declaration, that adds a partial to every page just above </body>
.
Deface::Override.new(
:virtual_path => 'spree/layouts/spree_application',
:name => 'add_piwik_tracking_tag_to_layout',
:insert_bottom => "[data-hook='body']",
:partial => 'spree/piwik')
The partial needs some variables. An example is a local or helper method:
_paq.push(['setSiteId', <%= piwik_site_id %>]);
or an instance variable:
_paq.push(['setSiteId', <%= @piwik_site_id %>]);
or entirely without variables:
_paq.push(['setSiteId', <%= Spree::Config.preferred_piwik_id %>]);
Is there any way to pass them along from the Deface::Override.new()
?
I am trying to avoid three potentially bad patterns, especially since this piwik_site_id
is one of many variables being passed in:
- Opening the application_helper from within my gem and insert a helper-method.
- Opening the
ApplicationController
and set a@piwik_site_id
there. Setting this on every controller, for every action and each template.
I'd prefer to not have to pollute the controllers of the application that have this gem available.