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

mumba-handlebars

v1.0.1

Published

A Handlebars service with several helpers.

Downloads

72

Readme

build status coverage report

Mumba Handlebars renderer

A Handlebars service with several helpers.

Helpers

ARRAY

Examples

Deprecated. Please progressively move examples to docblocks and move references to the list above.

Dates

<p>Format a date {{date created_at format="YYYY/MM/DD HH:mm:ss Z"}} (automatically parse the zone if provided)</p>
<p>Format a date with fixed timezone {{date created_at format="YYYY/MM/DD HH:mm:ss Z" tz="Australia/Perth"}}</p>
<p>Format a date with timezone in `this` {{date created_at format="YYYY/MM/DD HH:mm:ss Z" tz="timezone"}}</p>
<p>Format a date with timezone in another object {{date created_at format="YYYY/MM/DD HH:mm:ss Z" tz=user.timezone}}</p>
<p>Format as 'some time ago' {{dateFromNow created_at}}</p>
<p>Check if a date in the past {{#if (datePast publish_start)}}past{{/if}}</p>
<p>Check if a date in the future {{#if (dateFuture publish_start)}}future{{/if}}</p>
<p>Add to a date {{dateAdd created_at '1' 'month'}} (uses moment.add)</p>
<p>Subtract from a date {{dateSubtract created_at '1' 'month'}} (uses moment.subtract)</p>
<p>Set to the end of a period {{endOf created_at 'month'}} (uses moment.endOf)</p>
<p>Set to the start of a period {{startOf created_at 'month'}} (uses moment.startOf)</p>
<p>Get now {{now}}</p>

Equality

<p>Equal {{#if (eq foo "bar")}}true{{else}}false{{/if}}</p>
<p>Equal to null {{#if (eq foo null)}}true{{else}}false{{/if}}</p>
<p>Not equal {{#if (ne foo "bar")}}true{{else}}false{{/if}}</p>
<p>Less than or equal to {{#if (lte foo 2)}}true{{else}}false{{/if}}</p>
<p>Greater than {{#if (gt foo 2)}}true{{else}}false{{/if}}</p>
<p>Greater than or equal to {{#if (gte foo 2)}}true{{else}}false{{/if}}</p>
<p>Chaining and {{#if (and (gt foo 1) (lt foo 3))}}true{{else}}false{{/if}}</p>
<p>Chaining or {{#if (or (eq foo false) (eq foo true))}}true{{else}}false{{/if}}</p>
import { ObjectBuilder } from 'mumba-handlebars';

const source = {
  // equalities
  eq: '{{#if (eq foo "bar")}}true{{else}}false{{/if}}'
};
const data = {
  foo: 'bar'
};
const builder = new ObjectBuilder(source);
const result = builder.build(source, data);
// result.eq == 'true'

Internationalisation

See Number.prototype.toLocaleString() .

<p>Number format {{numf num}}</p>
<p>Accepts any options for `toLocaleString`, for example:</p>
<p>Number format {{numf num maximumFractionDigits="1"}}</p>
<p>Currency format {{curf num}}</p>
<p>- Defaults to AUD</p>
<p>- Accepts any options for `toLocaleString`, for example:</p>
<p>Currency format {{curf num locale="fr-DE" currency="EUR"}}</p>

Markdown

{{{markdown body}}}

Math

<p>Any Math object method {{math "sign" num}}</p>
<p>Add {{add num -0.05}}</p>
<p>Subtract {{subtract num 0.05}}</p>
<p>Multiply {{multiply num 2}}</p>

Regular expression

<p>{{rxmatch str "^ESCT ([-\\d.\']+)"}}</p>
<p>- If str = 'ESCT -17.5%', returns '-17.5'</p>

{{first (rxsplit "full name")}}
<!-- full -->

{{last (rxsplit "waz-up" "-")}}
<!-- up -->

Strings

<p>Formated printing {{sprintf "%s %.2f" str num }}</p>
<p>Concat {{concat "foo" foo 123}}</p>
<p>Contains any of the string {{#if (in foo "ptx" "lsl")}}YES{{else}}NO{{/if}}</p>
<p>Extract initials {{initials name}}</p>
<p>Convert JSON string to object {{#with (or value (json \'{"test":"no"}\'))}}{{test}}{{/with}}</p>
<p>String starts with {{#if (startswith foo "ptx")}}YES{{else}}NO{{/if}}</p>
<p>
  Time (in minutes) to read at 265 WPM {{timeToRead wordCount}}, see
  https://help.medium.com/hc/en-us/articles/214991667-Read-time
</p>
<p>Inspect (JSON stringify) {{inspect foo}} - Good for debugging!</p>

URLs

<p>{{encodeUriComponent "http://localhost/test #1" }}</p>
<p>{{decodeUriComponent "http%3A%2F%2Flocalhost%2Ftest%20%231" }}</p>

License

Apache-2.0


See working with microservices for more information on how to test this package.

© 2019 Mumba Pty Ltd. All rights reserved.