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

gulp-posthtml

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-posthtml

Gulp PostHTML Plugin

  • 3.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
613
increased by23.34%
Maintainers
3
Weekly downloads
 
Created
Source

npm node deps tests coverage code style chat

Gulp PostHTML

Install

npm i -D gulp-posthtml

Usage

import { task, src, dest } from 'gulp'

import posthtml from 'gulp-posthtml'

task('html', () => {
  return src('src/*.html')
    .pipe(posthtml())
    .pipe(dest('dest'))
})

Options

Plugins

NameTypeDefaultDescription
plugins{Array}[]PostHTML Plugins

Options

NameTypeDefaultDescription
options{Object}{}PostHTML Options

gulpfile.js

import { task, src, dest } from 'gulp'

import tap from 'gulp-tap'
import rename from 'gulp-rename'
import posthtml from 'gulp-posthtml'

task('html', () => {
  let path

  const plugins = [ require('posthtml-include')({ root: path }) ]
  const options = { parser: require('posthtml-sugarml')() }

  return src('src/*.html')
    .pipe(tap((file) => path = file.path))
    .pipe(posthtml(plugins, options))
    .pipe(rename({ ext: '.html' }))
    .pipe(dest('dest'))
})

Config

NameTypeDefaultDescription
plugins{Array}[]PostHTML Plugins
options{Object}{}PostHTML Options

gulpfile.js

import { task, src, dest } from 'gulp'

import rename from 'gulp-rename'
import posthtml from 'gulp-posthtml'


task('ssml', () => {
  const config = (file) => ({
    plugins: [ require('posthtml-include')({ root: file.dirname }) ],
    options: { parser: require('posthtml-sugarml')() }
  })

  return src('src/*.sml')
    .pipe(posthtml(config))
    .pipe(rename({ ext: '.html' }))
    .pipe(dest('dest'))
})

posthtml.config.js

Context
NameTypeDefaultDescription
env{String}'development'process.env.NODE_ENV
file{Object}dirname, basename, extnameFile
options{Object}{}Options (Parser, Render, Plugin Options)

posthtml.config.js

module.exports = ({ file, options, env }) => ({
  parser: 'posthtml-sugarml'
  plugins: {
    'posthtml-include': { root: file.dirname },
    'posthtm-expressions': { locals: options.locals }
    'htmlnano': env === 'production' ? {} : false
  }
})

gulpfile.js

import { task, src, dest } from 'gulp'

import rename from 'gulp-rename'
import posthtml from 'gulp-posthtml'


task('ssml', () => {
  const ctx = { locals: { a: 'Hello World!'} }

  return src('src/*.sml')
    .pipe(posthtml(ctx))
    .pipe(rename({ ext: '.html' }))
    .pipe(dest('dest'))
})

Maintainer


Ivan Voischev

Contributors


Michael Ciniawsky

Keywords

FAQs

Package last updated on 26 Jun 2020

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