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

gravy-bind

v1.3.0

Published

Hassle-free one-way binding for legacy and predominantly server-side apps

Downloads

508

Readme

GravyBind Version Downloads Build Status

Hassle-free one-way binding for predominantly server-side apps

[ npm | GitHub | Demo ]

Quick Start

Add a reference to the script

<script type="text/javascript" src="https://unpkg.com/gravy-bind/dist.browser/index.js"></script>

Create a binder

let binder = new GravyBinder();

Or provide a variable scope (default is just window)

const binder = new GravyBinder({firstName: '', lastName:''});

Or limit scanning to just part of the DOM tree

const binder = new GravyBinder(myScope, document.getElementById('rootNode'));

Start binding stuff!

<input data-in="this.firstName">
<b>You entered:</b>
<span data-display="this.firstName"></span>

What is it?

Say hello to GravyBind! This utility lets you bind things in your HTML to JavaScript variables.

Let me start off by saying that this is not a good alternative to anything more fully-featured like Vue or React. This is meant for simple scenarios where you want to just add some dynamism to an application that's either simpler or older without making major changes or making a big mess.

In the case I originally created this for, we had a .NET Core MVC project with jQuery spaghetti that was quickly becoming a nightmare to maintain as the app's complexity increased. I needed a simple way to update things like display values, class bindings, and native HTML validation properties in a more declarative way than a bunch of random query selectors. GravyBind uses data attributes to handle binding, so your markup and bindings are in the same place and it's easy to see how things are connected. There is no change tracker, it literally refreshes all the bindings when you tell it to so this probably isn't the most optimized thing around. Feel free to open a pull request if you have some performance improvements in mind.

Again, if you're building a new app, I strongly recommend using a popular frontend framework or library. However when limitations prevent that, this can come in handy.

With that out of the way, let's take a look at what this can do!

Docs & Demo

See the demo page for usage and examples: gravybind.halomademeapc.com

Planned Features

  • Loops and templating
  • Radio button support
  • Two-way binding on inputs

Changelog

  • 1.2.0 Add support for dynamically registering binding types, add more built-in bindings
  • 1.1.0 Replace eval calls with new Function, limit JavaScript scope of evaluations