pug-plugin-try-catch

1.2.0 • Public • Published

pug-plugin-try-catch

Dependency Status Build Status NPM version

An extension to the pug templating language to allow for try/catch statements.

Requirements

Use pug 2.x.

Use node v6.x.

Installation

$ npm install --save pug-plugin-try-catch

Usage

var pug = require('pug');
 
var src = `
.foo
  try
    p= obj.exists
  catch
    h2 Something busted!
`;
 
// To use, pass pug-plugin-try-catch into plugins.
var output = pug.compile(src, { plugins: [require('pug-plugin-try-catch')]});
 
console.log(output({ obj: { exists: 'hello world' } }));
// <div class="foo"><p>hello world</p></div>
 
console.log(output({ obj: null }));
// <div class="foo"><h2>Something busted!</h2></div>
 

License

MIT

Package Sidebar

Install

npm i pug-plugin-try-catch

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • austindebruyn