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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@b-side/parser

v4.3.4

Published

HTML Parser used to parse HTML string and bind data to it.

Downloads

244

Readme

@b-side/parser

HTML-like string async parser with automatic update of the resulting HTML if needed. Supports b-side logical custom-elements bs-if, bs-elseif, bs-else, bs-endif and bs-for. No W3C standards are validated while parsing the HTML string.

Installation

npm install @b-side/parser

Basic Usage

The Parser takes a String as entry and tries to convert it to b-side elements that can then be re-used by the renderer and/or converted back to String.


import { BSide } from '@b-side/parser';

const bside = BSide({
    data: { variable: 'This is a new text' },
    template: `<div>{{ variable }}</div>`,
});

const string = bside.toString(); // <div>This is a new text</div>

Supported logic

The content of the first conditional tag of the group will be added if the expression resolve to true. The content of the bs-else tag will be added if no other tags of the group have been resolved first.

Conditional

<bs-if (expression)>
</bs-if>
<bs-elseif (otherExpression)>
</bs-elseif>
<bs-else>
</bs-else>

Iteration

The content of the iteration tag will be repeated the number of time the expression will dictate. The variable must have a Symbol.iterator property or be a type number.

<bs-for (value, key of expression)>
</bs-for>

Options

All options are optionnals, but template option is most likely required if you want to parse something.

data

Object used to work with the template. Any property in this object can be used directly in the template option. Properties of the object are proxied so the content of the resulting HTML can automatically be updated when a change of data occurs.

Record<string, unknown>

element

HTMLElement in which the innerHTML will be replaced by the template option. If no data option is provided when using this option, element will be considered as the data option to use in the template.

HTMLElement

template

HTML-like string with no W3C standards enforced. Supports b-side logical tags explained before.

String

Advanced Usage

If you are working with custom-elements, it would be easier to just use the @b-side/base-element library. Usage of this library is wrapped inside custom elements.

Using element option

Using this option, the innerHTML of the HTMLElement will be replaced by the template string provided and updated automatically if/when needed.

import { BSide } from '@b-side/parser';

const data = { variable: 'This is a new text' };

BSide({
    data,
    element: document.querySelector('body'),
    template: `<div>{{ variable }}</div>`,
});

// <body>
//     <div>This is a new text</div>
// </body>

Automatic updates

Using javascript native Proxy, the properties of the data or element passed in options is watched an update of the resulting HTML string is updated if/when needed. Using previous example.

data.variable = 'This library is awesome';

// <body>
//      <div>This library is awesome</div>
// </body>

Can also be used globaly

Depending on the context, you might need to use the library in a global context. This could be done if you build and include the library in your HTML page the following way.

<script src="b-side.parser.js"></script>
<script>
    window['BSide']({
        data,
        template,
    })
</script>