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

ctxify

v0.5.0

Published

Interpolate variables into HTML graph described as JSON - return String for Node.js and HTMLElement in the browser.

Downloads

11

Readme

ctxify

ctxify(HTML graph, Context object) -> data interpolated into template

Clientside, presents a simple global function that converts deep objects into DOM trees

Also every child created from this tree has a props property that offers easy getting and setting of HTML attributes.

ctxify({div: {
	id: 'whateverYouWant', 
	textContent: 'This becomes a text node'
}})
// <div id="whateverYouWant"> This becomes a text node </div>

You can provide a second argument which will serve as an object to search for keys referenced in {{curly.bracket.delimited.dot.notation}} in any string in your HTMLX graph.

let prefixStyle = fs.readFileSync('./conf/prefixConfig.css')

ctxify({"style": {
	"textContent": "{{prefixStyle}}"
}}, { prefixStyle })

Here, an object with a single key, prefixStyle, with the property of the contents of .conf/prefixConfig.css, will be transformed into a style tag with the file contents.

Serverside, provides a module for server side rendering, interpolating data objects into your HTMLX objects and returning the HTML string.

This is presently syncronous, but it doesn't have to be...

I'll admit that bin/validateGraph is a pretty amatuer attempt at keeping a stack: I thought it would be nice to give a position.subposition.subsubposition path to where the validation failed (ran into unexpected value or type), so all my functions are redefined on every recursion with the position value passed in to the new scope. There's a better way to do this or maybe a better way to use error.stack than re-implementing it, but I haven't dug into it enough.

Curent Version: 0.2.0

Serverside interpolates context with htmlx

No weird this binding, just pass optional context as 2nd argument.

If you want to pass in text of some file to the textContent of some object, instead of having to read the file inside of the mergectx function, make sure you have the file read before you start: pass in the text as a JS object property.

Next Version: 0.3.0

More documentation for serverside & clientside Clientside context interpolation is coming up next

ChildNodes is an array including {tagName: {props}} objects and strings: strings should be filepaths --> I'll try to require that path, assuming its a JSON file, in which case it will be used as the sub graph for that child