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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsonml-ext

v1.0.2

Published

JSONML to HTML with extended functionality

Downloads

8

Readme

Banner

JSON Markup Language - Extended

npm Travis Codecov

Extended renderer for JSON Markup Language. Renders JSONML to a HTML string with addition of Emmet's abbreviation expander

Motivation

This project exists to compile JSON Markup language to HTML with the added benefit of using Emmet's abbreviations to simplify the code and workflow.

Installation

yarn add jsonml-ext

This will install the package into your project.

Usage & options

Read the JSONML website for more information on JSONML.

Once installed, you can import and render JSON ML arrays into HTML strings:

const {compile} = require('jsonml-ext');

compile(['div']);
// <div></div>

compile(['button', {class: 'red', disabled: true}]);
// <button class="red" disabled='true'></button>

compile(['div', ['a', {target: '_blank' }]]);
// <div><a href=' target='_blank'></a></div>

The JML Item The JML item passed in contains up to 3 items:

  1. The Emmet abbreviation to be expanded. EG: a#clickme[target='_blank']
  2. The attributes as a JSON object, OR a nested array of JML items
  3. Array of JML items. This item can only be passed if the attributes in item 2 was passed

EG: Simple usage

// Pass in only the first item
compile(['div#test'])
// '<div id='test'></div>'

Text content usage

// Pass in only the first item
compile(['div#test', 'Lorem Ipsum'])
// '<div id='test'>Lorem Ipsum</div>'

Attribute usage

// Pass in the first item and it's attributes
compile(['div[class="red"]', {class: 'override'}, 'Lorem Ipsum'])
// '<div class="override">Lorem Ipsum</div>'

Nested variation 1

// Omit the attributes
compile(['div[class="red"]', ['span', 'Nested content']])
// '<div class="red"><span>Nested content</span></div>'

Nested variation 2

// Pass in the first item, and it's attributes as the SECOND item. The remaining
// items are just JMLItems
compile(['div[class="red"]', {class: 'override'}, ['span']])
// '<div class="override"><span></span></div>'

Siblings

// You can pass as many JMLItems at the end of the array, and they will be added
// as siblings
compile(['div[class="red"]', ['span.sibling1'], 'text content', ['span.sibling2']])
// '<div class="override"><span class="sibling1"></span>text content<span class="sibling2"></span></div>'

Contributions

All pull requests and contributions are most welcome. Let's make the internet better!

Moving forward / TODO

  • [x] Add tests

Issues

If you find a bug, please file an issue on the issue tracker on GitHub.

Credits

This project is built and maintained by Tristan Matthias.