EzDevInfo.com

plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!

Change Google Analytics code using Plates

Is there a way to change the Google Analytics code included in a template using Plates?

For example, for the below template:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <script id="googleAnalytics">
        var _gaq=[['_setAccount','GA_ACCOUNT_CODE'],['_trackPageview']];
        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
        g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
        s.parentNode.insertBefore(g,s)}(document,'script'));
        </script>
    </body>
</html>

I would like to use a different GA_ACCOUNT_CODE depending on the environment the code runs in.

Is this possible with Plates? If not, what is the common way one would solve this issue in NodeJS & Flatiron?


Source: (StackOverflow)