Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Add layouts ability to ejs for different frameworks
JavaScript
Branch: master
Failed to load latest commit information.
README.md basic readme file
index.js removing dumb console.log
package.json adding github repo to package.json

README.md

EJS Layouts

EJS Layouts aims to add layout capibilities to frameworks for ejs.

Install

npm install ejs-layouts

Usage

Layout.ejs

<html>
    <head>
        <title><%- title %></title>
  <body>
    <%- content %>
  </body>
</html>

Home.ejs

<div>
  <%- name %>! Welcome to my site!
</div>

Express

var express = require('express')
var ejs_layout = require('ejs-layouts');

var app = express();

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(ejs_layout.express);
  app.use(app.router);
});

server.listen(3000);

app.get('/', function(req, res) {
  res.layout('Layout', {title:"Homepage"}, {content:{block:"Home", data:{name:"Matthew"}}});
});

Result

<html>
    <head>
        <title>Homepage</title>
  <body>
    <div>
      Matthew! Welcome to my site!
    </div>
  </body>
</html>
Something went wrong with that request. Please try again.