JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 154
  • Score
    100M100P100Q110470F
  • License ISC

get Pug code block

Package Exports

  • pug-code-block

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pug-code-block) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Pug code block

Get Pug (Jade) code at and inside a given line or query.

doc.jade

doctype html
html
  head
    title my jade template
  body
    h1 Hello #{name}
    p foo

Get block at line number

Will return a string for a single match, an array of code blocks for multiple matches.

var source = fs.readFileSync('./doc.jade', 'utf8');

var getCodeBlock = require('pug-code-block');
getCodeBlock.byLine(source, 2);

// head
//   title my jade template

Optionally provide a limit of blocks to be captured. Default limit is 1. Use Infinity if you want to capture all blocks.

var source = fs.readFileSync('./doc.jade', 'utf8');

var getCodeBlock = require('pug-code-block');
getCodeBlock.byLine(source, 1, 3);

// div yep
// div yep
// div yep
// div nope
// div nope

Get block at string match

Will return a string for a single match, an array of code blocks for multiple matches.

var source = fs.readFileSync('./doc.jade', 'utf8');

var getCodeBlock = require('pug-code-block');
getCodeBlock.byString(source, 'body');

// body
//   h1 Hello #{name}
//   p foo