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

knockout-interpolate

v0.4.0

Published

Knockout binding provider that does a one-time replacement of {{ expression }} blocks with data from the view model.

Downloads

11

Readme

knockout-interpolate

What is this plugin?

This library augments Knockout's default binding provider by adding support for interpolating text while Knockout is visiting each node to determine if it has bindings. This text replacement is designed to be done in a one-time manner (does not react to observables being updated). You would use this functionality in cases where you do want to use text from your view model, but do not need/want the overhead of a binding.

While the replaced text would not react to changes, a common use case may be inside of a container that is bound using the template or with binding such that the entire area would get swapped out. Values support context variables ($root, $parent, etc.) and expressions. For interpolation that converts to a containerless binding check out: http://mbest.github.io/knockout.punches/.

The library also allows similar one-way bindings that are not tracked and do not update using the data-koset attribute. The syntax is the same as data-bind, and currently supports visible, if, value, attr, and css bindings.

Note

The css binding depends on either your browser supporting classList, or jQuery being present. If neither of those conditions is satisfied, any usage of the css binding with data-koset will fail silently.

Examples

<div>First name: {{ first }}</div>
<div>Last name: {{ last }}</div>
<div>Full name: {{ first() + " " + last() }}</div>
<div>User: $root.userName</div>

<div data-koset='visible: x'></div>
<div data-koset='if: y'>XXX</div>
<select><option data-koset='value: z'></option></select>
<a data-koset="attr: { href: '#contacts/details/' + id }">{{ name }}</a>
<a data-koset="css: { active: isActive }">{{ name }}</a>

Once you've loaded the library, you enable it like:

ko.bindingProvider.instance = ko.bindingProvider.interpolate;