title: How do you use templates to generate dynamic HTML tag attributes in meteor?
body: <p>I am using a Template to Generate HTML Tag Attributes in Meteor, but is seems to be broken. I can't put a template inside an HTML tag in <a href="http://meteor.com/" rel="nofollow noreferrer">meteor</a> and I want to know why. </p>
  
  <p>I'm using <a href="https://github.com/tmeasday/meteor-router" rel="nofollow noreferrer">meteor-router</a> for routing. Since meteor basically only allows a single layout, I wanted to add a class to the body indicating the current view name, like so:</p>
  
  <p>/client/layout.html:</p>
  
  <pre><code>&lt;head&gt;
    &lt;title&gt;Meteor App&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body {{&gt; body-attributes}}&gt;
    {{renderPage}}
  &lt;/body&gt;
  
  &lt;template name="body-attributes"&gt;data-view-name="{{page}}" class="{{page}}"&lt;template&gt;
  </code></pre>
  
  <p>So that I could do this in /client/layout.js:</p>
  
  <pre><code>Template['body-attributes'].page = function () {
    return Meteor.Router.page();
  };
  </code></pre>
  
  <p>But that didn't work, I got an error from the app saying that attributes on the body are not supported. Changing layout.html to this:</p>
  
  <pre><code>&lt;head&gt;
    &lt;title&gt;Meteor App&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div {{&gt; body-attributes}}&gt;
        {{renderPage}}
    &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;template name="body-attributes"&gt;data-view-name="{{page}}" class="layout-container {{page}}"&lt;template&gt;
  </code></pre>
  
  <p>Resulted in totally broken HTML. The browser shows a '>' before the page, and the console elements panel looks like so:
  <img src="https://i.stack.imgur.com/aBf6g.png" alt="Console screenshots"></p>
  
  <p>Why doesn't that work?</p>