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

hbs-markdown-helpers

v1.1.1

Published

hbs-markdown-helpers provides some markdown helpers for use in the handlebars template.

Downloads

4

Readme

HBS-MARKDOWN-HELPERS

hbs-markdown-helpers provides some markdown helpers for use in the handlebars template.

Installing

npm i hbs-markdown-helpers

Usage Exemple

import * as handlebars from "handlebars";
import {HbsMarkdownHelpers} from 'hbs-markdown-helpers';

// Firstly you must create a new instance of HbsMarkdownHelpers
const markdownHelper = new HbsMarkdownHelpers({
      configTable: {
        customFormatDate: "dd/mm/yyyy", // default format: yyyy-mm-dd
        customLabelBoolean: { true: "Sim", false: "Não" }, // default label : {true: "Yes", false: "No"}
      },
});

// Then get the helpers
const helpers = markdownHelper.getMarkdownHelper();

// And register in Handlebars
handlebars.registerHelper(helpers);

HbsMarkdownHelpers

  interface Config {
    configTable?: { 
        // You must use "yyyy" for the year, "mm" for the month, and "dd" for the day  
      customFormatDate?: string, // default format: yyyy-mm-dd
      customLabelBoolean?: { true: string, false: string }, // default label : {true: "Yes", false: "No"}
    },
}

Params

  • config?: Config

Helpers

{{md_array}}

Return an array

Params

  • data: string

    Comma separated element

Usage Exemple

<!--Comma separated element-->
{{md_array "Name,Age"}}

{{md_table}}

Return a table.

Params

  • data: Array<Object>
  • headers?: Array<string>

    Array with custom name headers

  • dataCells?: Array<string>

    Array with data property names

  • align?: center | left | right

    Table alignment. defaul: left

Usage Exemple
Template:
<!-- data: [{
      "name": "Rodrigo",
      "lastName": "Limões",
      "age": 23,
      "birthData": "1998-9-21",
      "isMatriculate": true,
      "subjects": ["JavaScript", "Reactjs", "Css"]
    },
    {
      "name": "João",
      "lastName": "Silva",
      "age": 20,
      "birthData": "2000-9-21",
      "isMatriculate": true,
      "subjects": ["TypeScript", "Nodejs", "Mongodb"]
    },
    {
      "name": "Julia",
      "lastName": "Silva",
      "age": 24,
      "birthData": "1997-9-21",
      "isMatriculate": false,
      "subjects": ["Reactjs", "TypeScript"]
    }] -->

<!--
    this - data
    headers - Array with custom name headers
    dataCells - Array with data property names
    align - Table alignment
 -->

**Without Params:**
<!-- Return a table with the value of all object properties -->
{{md_table this }}

**With Params:**
<!-- Return a center-aligned table with a custom header and name and age property values -->
{{md_table this headers=(md_array "Name,Age") dataCells=(md_array "name,age") align="center"}}
Output:

Without Params:

| NAME | LASTNAME | AGE | BIRTHDATA | ISMATRICULATE | SUBJECTS | |:---------|:-------------|:--------|:--------------|:------------------|:--------------------------------| | Rodrigo | Limões | 23 | 1998-09-21 | Yes | JavaScript, Reactjs, and Css | | João | Silva | 20 | 2000-09-21 | Yes | TypeScript, Nodejs, and Mongodb | | Julia | Silva | 24 | 1997-09-21 | No | Reactjs, and TypeScript |

With Params:

| Name | Age | |:--------:|:-------:| | Rodrigo | 23 | | João | 20 | | Julia | 24 |


{{md_checklist}}

Return a checkList

Params

  • data: Array<object>
  • propLabel?: string

    Name property from object

  • propChecked?: string

    Name property from object

Usage Exemple

<!-- data: [{
      "checked": true,
      "otherChecked": false,
      "label": "Text Label 1",
      "label2": "Text Label 2"
    },
    {
      "checked": false,
      "otherChecked": true,
      "label": "Text Label 1",
      "label2": "Text Label 2"
    },
    {
      "checked": true,
      "otherChecked": false,
      "label": "Text Label 1",
      "label2": "Text Label 2"
    }] -->

<!-- 
    this - data
    propLabel - Name property from object
    propChecked - Name property from object
 -->
**CheckList with params**
<!-- Return a checklist with value of propChecked and propLabel -->
{{md_checklist this propLabel="label2" propChecked="checked"}}
_________________
<!-- Return a checklist with value of propChecked -->
{{md_checklist this propChecked="otherChecked"}}
_________________
<!-- Return a checklist with value of propLabel -->
{{md_checklist this propLabel="label2"}}

**CheckList without params**
<!-- Return a checklist with first boolean value and first string value -->
{{md_checklist this.todoList}}

output:

CheckList with params

  • [X] Text Label 2
  • [ ] Text Label 2
  • [X] Text Label 2

  • [ ] Text Label 1
  • [X] Text Label 1
  • [ ] Text Label 1

  • [X] Text Label 2
  • [ ] Text Label 2
  • [X] Text Label 2

CheckList without params

  • [X] Text Label 1
  • [ ] Text Label 1
  • [X] Text Label 1

{{md_checkbox}}

Return a checkbox

Params

  • checked: boolean
  • label: string

Usage Exemple

**Checkbox**
{{md_checkbox checked=true label="Label"}}
{{md_checkbox checked=false label="Label"}}

output:

Checkbox

  • [X] Label
  • [ ] Label

{{md_link}}

Return a markdown Link

Params

  • textLink: string
  • url: string

Usage Exemple

**Link**
{{md_link textLink="Rodrigo" url="https://github.com/rodrigolimoes"}}

output:

Link

Rodrigo


{{md_image}}

Return a markdown Image

Params

  • path: string
  • description: string

Usage Exemple

**Image**

{{md_image path="./__tests__/data/image/image_test.png" description="Table Example of hbs-markdown-helpers library"}}

output:

Image

Table Example of hbs-markdown-helpers library


{{md_image_link}}

Return a markdown Image Link

Params

  • path: string
  • description: string
  • url: string

Usage Exemple

**Image Link**
{{md_image_link path="./__tests__/data/image/image_test.png" description="Table Exemple of hbs-markdown-helpers" url="https://github.com/rodrigolimoes/hbs-markdown-helpers/blob/main/__tests__/data/image/image_test.png"}}

output:

Image Link

Table Exemple of hbs-markdown-helpers