Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Passing a variable named "body" to a view when using a layout causes that variable to render as the layout body #22

Open
atuttle opened this Issue · 0 comments

1 participant

@atuttle

views/layout.ejs:

<!DOCTYPE html>
<html>
  <head>
    <title>test</title>
  </head>
  <body>
    <%- body -%>
  </body>
</html>

views/post.ejs:

<% layout('layout') -%>
<h1><%= title %></h1>
<p><%= body %></p>

Route:

exports.index = function(req, res){
    res.render('index', { title: 'this is a test', body: 'test body' } );
};

Renders:

<!DOCTYPE html>
<html>
  <head>
    <title>test</title>
  </head>
  <body>
    test body
  </body>
</html>

Expected:

<!DOCTYPE html>
<html>
  <head>
    <title>test</title>
  </head>
  <body>
    <h1>this is a test</h1>
    <p>test body</p>
  </body>
</html>

I've since changed my view to use "content" instead of "body" but thought it was best to bring this up. If it's expected behavior, you might want to add it to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.