Socket
Socket
Sign inDemoInstall

gulp-multi-renderer

Package Overview
Dependencies
97
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-multi-renderer

plugin to render contents using various template engines.


Version published
Maintainers
1
Install size
4.83 MB
Created

Readme

Source

gulp-multi-renderer

plugin to render contents using various template engines.

Install

npm install --save-dev gulp-multi-renderer

Usage

gulpfile.js

var frontMatter = require('gulp-front-matter');
var marked = require('gulp-marked');
var renderer = require('gulp-multi-renderer');

gulp.src('./src/*.md')
  .pipe(frontMatter({
    remove: true
  }))
  .pipe(renderer({
    target: "content"
  }))
  .pipe(marked())
  .pipe(renderer({}))
  .pipe(gulp.dest('./dist'));
});

markdown with YAML front matter.

---
title: My Awesome Document
---

Hello, This is <%- frontMatter.title %>.


after pre-process.

Hello, This is My Awesome Document.

layout/default.ejs

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title><%= frontMatter.title %></title>
    </head>
    <body>
      <%- contents %>
    </body>
</html>

after post-process.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title>My Awesome Document</title>
    </head>
    <body>
      <p>Hello, This is My Awesome Document.</p>
    </body>
</html>

API

render(options)

options

Type: hash Default: { target: "wrap", property: "forntMatter", templateDir: "./layouts"}

options.target

Type: String Default: wrap

When content is specified, it render embedded template within file.contents. Default template is ejs. If you want to user mustache, set mustache to frontMatter.local.

When wrap is specified, you can refer file.contents through contents variable in the template file. Default template file is ./layouts/default.ejs. You can specify template file by frontMatter.layout. You can also use mustache or jade for template file.

options.property

Type: String Default: forntMatter

a Object name of which contains local variables.

options.templateDir

Type: String Default: ./layouts/

A directory in which template files are placed.

License

MIT License

Keywords

FAQs

Last updated on 04 Nov 2014

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc