JavaScript Data Inside post_content


Get access to JavaScript variables such as tags or section name for use in JavaScript snippets, such as ad targeting.


  1. Create a new file inside mustache/roar/post/ folder. Let's call it post_scripts.html.
  2. Include it in your dynamic_content/postpage.xml template.
  3. <post_content template="roar/post/post_scripts" filters="section" />
  4. Add the <script> to your newly created file. Example:
  • <script>
        // get author name. If article has no author, default to 'unknown'.
        var author = "{{#original_user_subsite}}{{original_user_subsite.title}}{{/original_user_subsite}}{{^original_user_subsite}}unknown{{/original_user_subsite}}";
        // initialize array of post tags
        var tags = [];
        // initialize array of sections.
        var sections = [];
        // for each tag, push the tag name into our 'tags' array.
        // for each section, push the section name into our 'section' array.
        // Note: this will usually only populate the primary section of the article, so array.length will be 1.
        // Check results in browser dev tools.
        console.log(author, tags, sections);

The {mustache} variables used can be found in your browser's console in dev tools under bootstrap object:

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like1 Follow
  • 2 yrs agoLast active
  • 280Views
  • 1 Following