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

@fyno/handlebars_helpers

v1.0.7

Published

Fyno Web SDK

Downloads

283

Readme

Handlebars Helper Documentation

This documentation provides details and examples for each custom Handlebars helper defined in the provided code.

1. isArray

Checks if the provided context is an array.

Example:

{{#isArray myArray}}
  <!-- Code to execute if myArray is an array -->
{{else}}
  <!-- Code to execute if myArray is not an array -->
{{/isArray}}

2. formatDate

Formats a date according to the specified format, locale, and timezone.

Example:

{{formatDate "2023-01-01T12:00:00" "medium" "en-us" "+05:30"}}

3. formatDateTime

Formats a date and time according to the specified format, locale, and timezone.

Example:

{{formatDateTime "2023-01-01T12:00:00" "medium" "en-us" "+05:30"}}

4. remove

Removes specified strings from the input string.

Example:

{{remove "Hello, world!" "world"}}

5. isJSON

Checks if the provided context is a JSON object.

Example:

{{#isJSON myObject}}
  <!-- Code to execute if myObject is a JSON object -->
{{else}}
  <!-- Code to execute if myObject is not a JSON object -->
{{/isJSON}}

6. ifEquals

Conditionally executes code based on equality.

Example:

{{#ifEquals variable1 variable2}}
  <!-- Code to execute if variable1 equals variable2 -->
{{else}}
  <!-- Code to execute if variable1 does not equal variable2 -->
{{/ifEquals}}

7. stringify

Converts an object to as json string

Example:

{{stringify myObject}}

8. parse

Parses a JSON string into an object.

Example:

{{#parse jsonString}}
  <!-- Access properties of the parsed object -->
  {{property1}}
{{/parse}}

9. ifMatches

Checks if a string matches a regular expression.

Example:

{{#ifMatches myString "pattern"}}
  <!-- Code to execute if myString matches the pattern -->
{{else}}
  <!-- Code to execute if myString does not match the pattern -->
{{/ifMatches}}

10. raw-helper

Returns the raw content without rendering Handlebars expressions.

Example:

{{#raw-helper}}
  <p>This is raw HTML content: {{variable}}</p>
{{/raw-helper}}

11. isEmail

Checks if the provided string is a valid email address.

Example:

{{#isEmail "[email protected]"}}
  <!-- Code to execute if the email is valid -->
{{else}}
  <!-- Code to execute if the email is not valid -->
{{/isEmail}}

12. getNumberFromText

Extracts a number from the given text.

Example:

{{getNumberFromText "The price is $500"}}

13. default

Provides a default value if the key is falsy.

Example:

{{default myKey "Default Value"}}

14. ifStartsWith

Conditionally executes code based on whether a string starts with a specified prefix.

Example:

{{#ifStartsWith myString "prefix"}}
  <!-- Code to execute if myString starts with "prefix" -->
{{else}}
  <!-- Code to execute if myString does not start with "prefix" -->
{{/ifStartsWith}}

15. isExpo

Extracts the Expo token from a string if present.

Example:

{{isExpo "expo_token:ABC123"}}

16. isFCM

Extracts the FCM token from a string if present.

Example:

{{isFCM "fcm_token:XYZ789"}}

17. isOnesignal

Extracts Onesignal selector and token from a string if present.

Example:

{{#isOnesignal "onesignal_player_id:12345"}}
  <!-- Access properties: {{onesignal_selector}}, {{onesignal_token}} -->
{{else}}
  <!-- Code to execute if the string does not match Onesignal format -->
{{/isOnesignal}}

18. isEmpty

Checks if an object is empty.

Example:

{{#isEmpty myObject}}
  <!-- Code to execute if myObject is empty -->
{{else}}
  <!-- Code to execute if myObject is not empty -->
{{/isEmpty}}

19. setVariable

Sets a variable in the root context.

Example:

{{setVariable "myVar" "myValue"}}

20. pushCallback

Pushes callback information into the root context.

Example:

{{pushCallback}}

21. generateNotifyId

Generates a notification ID based on the provided key.

Example:

{{generateNotifyId "myKey"}}

22. dateDiff

Calculates the difference between two dates.

Example:

{{dateDiff "2023-01-01T12:00:00" "NOW" "days"}}

23. compare

Compares two values based on the specified operator.

Example:

{{#compare value1 "eq" value2}}
  <!-- Code to execute if value1 equals value2 -->
{{else}}
  <!-- Code to execute if value1 does not equal value2 -->
{{/compare}}

24. eq, ne, lt, gt, lte, gte, and, or

Logical comparison helpers.

Example:

{{#eq variable1 variable2}}
  <!-- Code to execute if variable1 equals variable2 -->
{{/eq}}

25. split

Splits a string into an array using a specified delimiter.

Example:

{{#split "apple,orange,banana" ","}}
  <!-- Access individual elements in the array -->
  {{this}}
{{/split}}

26. math

Performs basic arithmetic operations on two values.

Example:

{{math 10 "+" 5}}

27. relativeDay

Determines the relationship of a given date to the current date.

Example:

{{relativeDay "2023-01-01"}}

28. trim

Trims a string to a specified length and delimiter.

Example:

{{trim "This is a long string" 10 "..."}}

29. formatNumber

Formats a number using the specified locale.

Example:

{{formatNumber 1234567.89 "en-US"}}