Skip to content

Rollup plugin that allows importing Pug templates as HTML strings

License

Notifications You must be signed in to change notification settings

KiaraGrouwstra/rollup-plugin-pug-html

 
 

Repository files navigation

Build Status npm Version License

rollup-plugin-pug-html

Rollup plugin that allows importing pug templates as HTML strings.

Installation

npm install --save-dev rollup-plugin-pug-html

Usage

Create the template:

//- template.pug
p Hello #{ name }

Import the template:

// main.js
import html from './template.pug';
console.log(html);  // <p>Hello World</p>

And build with something like...

import { rollup } from 'rollup';
import pug from 'rollup-plugin-pug-html';

rollup({
  entry: 'src/main.js',
  plugins: [
    pug({
      // By default, all .jade and .pug files are compiled
      // extensions: [ '.jade', '.pug' ],
      // You can restrict which files are compiled
      // using `include` and `exclude`
      include: 'src/components/**.pug',
      // You can use native pug options as well.
      pretty: true,
      // You can also pass context for the Pug variables:
      context: { name: 'World' },
    })
  ]
}).then(...)

That's it.

Options

This plugin is using the following pug options as defaults:

{
  doctype: 'html',
  name: 'template',
  compileDebug: false,
  inlineRuntimeFunctions: false,
  context: {},
}

See the full list and explanation in the API Documentation of the Pug site.

Licence

MIT

About

Rollup plugin that allows importing Pug templates as HTML strings

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.4%
  • HTML 5.6%