Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bm-express-block

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bm-express-block

Html or text block for Express views

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bm-express-block

Express middleware for using html or text block in views, support ejs jade etc. view engines.

Examples

Basic

You can view example code here.

layout.ejs

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <%- setBlock('title', 'base', 'Myapp - ') %>
    <title><%- blocks.title %></title>
    <%- blocks.header %>
  </head>
  <body>
    <%- body %>

    <%- blocks.footer %>
  </body>
</html>

index.ejs

<%- setBlock('title', 'index', 'Site Home') %>

<h1>My Site</h1>
<p>Welcome to My Site</p>

user.ejs

{{base}} is used for inherit block html content of parent template.

E.g. {{base}}User will output 'Myapp - ' set by layout.ejs before 'User', so the whole output is 'Myapp - User'.

<%- setBlock('title', 'user', '{{base}}User') %>

<h1>users</h1>

<%- setBlock('footer', 'user',
  '<script>var userId = ' + id + ';</script>' +
  '<script src="/js/user.js"></script>'
  ) %>

Usage

Installation

npm install bm-express-block --save-dev

Use in your Expressjs application

// Require it
var bmExpressBlock = require('bm-express-block');

var app = express();
// Add this line after you create instance of Expressjs
app.use(bmExpressBlock());

Api

blocks

<%- blocks.name %>

View object for outputting named block html

setBlock()

<%-setBlock(name, scope, html) %>

View method for adding the given HTML to the named block

Release History

  • 2015-12-13 v1.1.0 Change init method, update doc
  • 2015-07-31 v1.0.0 Initial commit

Keywords

FAQs

Package last updated on 20 Dec 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc