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

express-render-template

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-render-template

Use the HTML source of an external URL as an express layout template (clean iframe alternative)

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by166.67%
Maintainers
1
Weekly downloads
 
Created
Source

express-render-template

This package in no longer supported and has been replaced by node-iframe-replacement

Use the HTML source of an external URL as an express layout template, a clean alternative to an iframe.

Extends res.render allowing an external URL to be used as a layout & CSS selector as a placeholder location to inject view content.

Installation

$ npm install --save express-render-template

Usage

The example below will request the Mammoth Workwear home page and replace the contents of #promo-banner with the contents of the view

var renderTemplate = require('express-render-template');

// replace res.render with renderTemplate version
app.use(renderTemplate);

// create a regular express route
app.get('/', function(req, res){
    
    // call res.render as normal but pass template and selector rather than layout
    res.render('view-name',{
       template: 'http://mammothworkwear.com',  // external url to use as layout page
       templateSelector: '#promo-banner'        // element within the layout to inject view content
    });
});

View template

<h1>20% off <a href="https://northseaworkwear.com/brands-dickies-fr-workwear/">Dickies Workwear</a></h1>

Auto base tag injection

To ensure scripts, styles and images in the external template load on your site, the render method injects a HTML base tag <base href="http://mammothworkwear.com" />. Therefore you need to ensure any links within your view are absolute.

License

ISC License © 2016 John Doherty

Keywords

FAQs

Package last updated on 02 Jan 2017

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