![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ejs-layout-chain
Advanced tools
Layout chain support for ejs in express 4.x
$ npm install ejs-layout-chain
var express = require('express');
var ejsLayoutChain = require('ejs-layout-chain');
var app = express();
app.set('view engine', 'ejs');
app.use(ejsLayoutChain);
app.get('/', function(req, res) {
var locals = {
title: 'Page Title',
description: 'Page Description',
header: 'Page Header',
layout: 'layout>category'
};
res.render('news', locals);
});
app.listen(3000);
contentFor
For example, consider this view:
foo
<%- contentFor('pageSectionA') %>
bar
<%- contentFor('pageSectionB') %>
baz
Using it with this layout:
<div class="header"><%- pageSectionA %></div>
<div class="body"><%- body %></div>
<div class="footer"><%-defineContent('pageSectionB')%></div>
Will render:
<div class="header">bar</div>
<div class="body">foo</div>
<div class="footer">baz</div>
Notice that the difference between using <%- pageSectionA %>
and <%-defineContent('pageSectionA')%>
is that the former will generate an error if the view doesn't define content for this section.
If you want to specify the layout you want to render a view in, instead of specifying one layout, you can specify a layout chain like 'layout1>layout2', this will render view as body of layout2, then layout2 as body of layout1.
For example, consider this view:
foo
<%- contentFor('pageSectionA') %>
bar
<%- contentFor('pageSectionB') %>
baz
Using it with layout1:
<div class="layout1-header"><%- pageSectionA %></div>
<div class="layout1-body"><%- body %></div>
<div class="layout1-footer"><%-defineContent('pageSectionB')%></div>
layout2:
<div class="layout2-header"><%- pageSectionA %></div>
<div class="layout2-body"><%- body %></div>
<div class="layout2-footer"><%-defineContent('pageSectionB')%></div>
<%- contentFor('pageSectionA') %>
<%- pageSectionA %>
<%- contentFor('pageSectionB') %>
<%-defineContent('pageSectionB')%>
as:
res.render('view', {layout: 'layout1>layout2'});
Will render:
<div class="layout1-header">bar</div>
<div class="layout1-body">
<div class="layout2-header">bar</div>
<div class="layout2-body">foo</div>
<div class="layout2-footer">baz</div>
</div>
<div class="layout1-footer">baz</div>
Clone the rep and run:
$ make test
MIT
FAQs
ejs layout chain level
The npm package ejs-layout-chain receives a total of 4 weekly downloads. As such, ejs-layout-chain popularity was classified as not popular.
We found that ejs-layout-chain demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.