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

vue-nested-list

v1.0.1

Published

Vue.js component for rendering JavaScript objects and arrays as nested HTML lists

Downloads

16

Readme

vue-nested-list

Vue.js component for rendering JavaScript objects and arrays as nested HTML lists. This can be handy to quickly get reasonable HTML output of complex data during prototyping.

The content passed into the component will be rendered as follows:

  • Objects as definition lists (<dl>) with keys (<dt>) and values (<dd>),
  • Arrayss as unordered lists (<ul>) with each item in a <li>,
  • Anything else in a <span>.

NPM

Usage

Register the component, for example globally:

const VueNestedList = require('vue-nested-list').NestedList;
Vue.component('nested-list', VueNestedList);

Now you can use in Vue.js templates. Let's say you have person object defined as a property on the data object:

var vue = new Vue({
	el: "#app",
	data: {
		person: {
			name: "John Smith",
			age: 25,
			hobbies: ["coding", "swimming", "whisky"],
			competencies: {
				"javascript": "strong",
				"vue.js": "good",
				"angularjs": "poor"
			}
		},
	}
})

You can now use the component in the Vue template:

<h1>{{person.name}}</h1>
<nested-list v-bind:content="person"></nested-list>

And the data will be output as dl and ul elements:

<h1>John Smith</h1>
<dl>
	<dt>name</dt> <dd><span>John Smith</span></dd>
	<dt>age</dt> <dd><span>25</span></dd>
	<dt>hobbies</dt> <dd>
		<ul>
			<li><span>coding</span></li>
			<li><span>swimming</span></li>
			<li><span>whisky</span></li>
		</ul>
	</dd>
	<dt>competencies</dt> <dd>
		<dl>
			<dt>javascript</dt> <dd><span>strong</span></dd>
			<dt>vue.js</dt> <dd><span>good</span></dd>
			<dt>angularjs</dt> <dd><span>poor</span></dd>
		</dl>
	</dd>
</dl>

To get nicely nested output across browsers when rendered, you will need a little CSS for the definition list, something like:

dt {
	font-weight: bold;
}
dt:after {
	content: ":"
}
dd {
	margin-left: 2em;
}

Install

$ npm install vue-nested-list

License

MIT