npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

brakkoli-pmb

v0.0.2

Published

An SGML (XML, HTML) template engine that uses arrays for hierarchy.

Readme

brakkoli-pmb

An SGML (XML, HTML) template engine that uses arrays for hierarchy.

Early Access Warning

This module is in the first stages of development. Expect major differences between docs and implementation.

Usage

from test/usage.js:

var brakk = require('brakkoli-pmb')(), spec,
  recipes = { basicPage: require('brakkoli-html5-pmb/basic_page') };

recipes.createAndSharePage = function (topic, answers) {
  var pg = recipes.basicPage({ indent: 2,
    title: 'Create & share ->your<- ' + topic,
    });
  pg.head.push({ link_css: 'quiz.css' });
  pg.body.push([ 'h1', pg.head.title ],
    [ 'form method="get" action="x-nope://"',
      [ 'ul class="quiz"'].concat(answers.map(recipes.checkboxAnswer)),
      [ 'input type="submit">' ],
      ]);
  return pg;
};

recipes.checkboxAnswer = function (ans) {
  return [ [ 'li', { indentTags: 0,  }, [ 'label',
      [ 'input type="checkbox" name="ingr[]">',
        { attr: { value: ans } } ],
      '\n  ', ans ] ], '\n' ];
};

spec = recipes.createAndSharePage('sandwich', [ 'bacon',
  'lettuce', 'tomato', 'cheese', 'onion',
  'hot & spicy sauce', 'mustard', '"Ben\'s beans"' ]);

tu.expectEqual(brakk(spec),   expectedHTML);
tu.expectEqual(spec,          expectedTree);

API

var brakkoliFactory = require('brakkoli-pmb'),
  brakk = brakkoliFactory(),    // <-- using default config
  customBrakk = brakkoliFactory({ tplSlotRx: /\{{2}([\w\-]*)\}{2}/g });

brakk expects one argument, spec, which should be an array. If multiple argument are given, spec is constructed internally as an array that contains the empty string, followed by all arguments.

brakk maintains a dictionary object fxcfg to keep track of special effects settings. The factory function accepts a single, optional argument fxdefaults with your favorite defaults for fxcfg.

spec's elements are processed, in original order, depending on their type:

  • undefined and null values are ignored.
  • Any non-Array object: Its keys are processed, in default sort order, as effect commands (see below).
  • Tag head: The first element that's neither of the above.
  • Tag content: All elements that are neither of the above.

All tag content is converted as described below and concatenated to construct the initial result string.

Tag head special effects

Currently, the only supported type of tag head is a string. If the tag head is not empty, the template effects (see below) are applied. If the tag head still is not empty, an opening tag is constructed from it, and is prepended before the result string. If the tag head ends with a character other than >, a closing tag is constructed and appended to the result string.

Tag content special effects

Arrays are converted using brakk, and special effect processing is skipped since it should have happened already, as part of the conversion.

All other values are String()ified and then special effects may be applied:

  • First, template effects.
  • If fxcfg.rawXml !== false, XML special characters are replaced like xmldefuse does in default mode.

Template effects

(to be documented)

Effect commands

  • store → Object upd: Object.assign(fxcfg.tplVars, upd);

Known issues

  • needs more/better tests and docs

 

License

ISC