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

handlebars-helper-md

v0.2.0

Published

Convert markdown to HTML. Use wildcard (glob) patterns for files. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.

Downloads

97

Readme

{{md}} NPM version

Convert markdown to HTML. Use wildcard (glob) patterns for files. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.

If you find a bug or have a feature request, please create an issue.

Installation

Install with npm:

npm i handlebars-helper-md --save-dev`

Install with bower:

bower install handlebars-helper-md --save-dev`

Register the helper

The easiest way to register the helper with Assemble is to add the module to devDependencies and keywords in your project's package.json:

{
  "devDependencies": {
    "handlebars-helper-md": "*"
  },
  "keywords": [
    "handlebars-helper-md"
  ]
}

Alternatively, to register the helper explicitly in the Gruntfile:

grunt.initConfig({
  assemble: {
    options: {
      // the 'handlebars-helper-md' npm module must also be listed in
      // devDependencies for assemble to automatically resolve the helper
      helpers: ['handlebars-helper-md', 'foo/*.js']
    },
    files: {
      'dist/': ['src/templates/*.hbs']
    }
  }
});

Usage Examples

With the helper registered, you may now begin using it in your templates:

{{md 'foo'}}

Gruntfile configuration

assemble: {
  options: {
    partials: ['test/fixtures/includes/*.md'],
  },
  files: {
    'dest/': ['src/*.{hbs,md}']
  }
}

Optionally pass in a context as the second parameter:

{{md 'foo' bar}}

Wildcard patterns

Globbing patterns may also be used:

{{md 'chapter-*' bar}}

Set marked.js options in the Gruntfile

assemble: {
  options: {
    // marked.js options
    marked: {
      sanitize: true,
      // see test/fixtures/render/heading.tmpl
      headings: 'anchors.tmpl'
    },
    partials: ['includes/*.md'],
  },
  files: {
    'dest/': ['src/*.{hbs,md}']
  }
}

Context

Like Assemble itself, this helper attempts to automatically determine the correct context to use based on the data supplied, but a context can be explicitly passed as a second parameter.

This is how data is merged into the context, in order of precedence:

  1. given context : a context explicitly passed as a second parameter, e.g. {{md 'foo' bar}}, will win over other contexts.
  2. YAML front matter : YAML front matter of the markdown file
  3. opts.data[name] : JSON/YAML data file defined in Assemble options.data with a basename matching the name of the markdown file, e.g {{md 'foo'}} matches foo.json
  4. this : A context of this likely means either YAML front matter of the "inheriting" page, the inheriting layout, block expression, or "parent" helper wrapping this helper
  5. Assemble options : Custom properties defined in Assemble options
  6. grunt.config.data : Data from grunt.config.data (e.g. pkg: grunt.file.readJSON('package.json'))

Related projects

Besides the handlebars-helpers library, which contains more than 120 helpers, Here are some related projects you might be interested in from the Assemble core team.

  • banners: Reusable banners for Node.js projects.
  • fs-utils: File utils from Grunt.js. This is temporary, we'll switch to grunt-file when it's published.
  • glob-object: Globbing for objects and properties.
  • glob-utils: Globbing utilities for Grunt.js and node.js projects.
  • grunt-helpers: Utils for grunt.js projects.
  • grunt-init-helper-mod: Grunt init template for creating a new helper module.
  • handlebars-helper-aggregate: {{aggregate}} handlebars helper. inlines content from multiple files optionally using wildcard (globbing/minimatch) patterns. uses YAML front matter as context for each file. optionally pass in a sorting function.
  • handlebars-helper-autolink: {{autolink}} handlebars helper. Generate relative links from the "current page" to other dest pages.
  • handlebars-helper-br: {{br}} Handlebars helper. Adds <br> tags to generated HTML. Great for prototyping.
  • handlebars-helper-compose: {{compose}} handlebars helper. Similar to {{aggregate}}, but this is a block expression helper that inlines content from multiple files differently, extracting YAML front matter to pass to context for each file. Optionally use wildcard (globbing/minimatch) patterns. Accepts compare function as 3rd parameter for sorting inlined files.
  • handlebars-helper-condense: Remove extra newlines from HTML content.
  • handlebars-helper-disqus: {{disqus}} Handlebars helper. Simplifies adding Disqus comments to your site.
  • handlebars-helper-eachitems: {{eachItems}} handlebars helper.
  • handlebars-helper-ghbtns: {{ghbtn}} handlebars helper. Add github buttons (http://ghbtns.com) to your site.
  • handlebars-helper-include: Handlebars helper, alternative to built-in partials. Similar to handlebars-helper-partial, but this helper will allow wildcard (glob) patterns. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.
  • handlebars-helper-isActive: {{isactive}} handlebars helper. Adds an 'active' class to the 'current page'. Class can be customized.
  • handlebars-helper-jade: {{jade}} handlebars helper, for converting basic Jade templates to HTML.
  • handlebars-helper-less: {{less}} handlebars helper. This helper allows you to use LESS inside style tags in your HTML. By default, the resulting CSS will be rendered inside the <style>...</style> tags of the rendered HTML, but you may alternatively define a destination path using the dest hash option of the helper.
  • handlebars-helper-lorem: {{lorem}} handlebars helper, for generating lorem lorem placeholder text.
  • handlebars-helper-minify: {{minify}} handlebars helper, for minification of HTML with html-minifier.
  • handlebars-helper-moment: {{moment}} handlebars helper. Combines the powers of Assemble, Handlebars.js and Moment.js into a great helper to master time.
  • handlebars-helper-not: {{not}} handlebars helper. Conditionally render a block if the condition is false. This block helper is really just a semantic alternative to {{isnt}}
  • handlebars-helper-paginate: {{paginate}} handlebars helper. Made for Assemble, the static site generator for Node.js, Grunt.js and Yeoman.
  • handlebars-helper-partial: Handlebars helper, alternative to built-in partials. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.
  • handlebars-helper-pkg: {{pkg}} handlebars helper, for retrieving a value from your project's package.json
  • handlebars-helper-post: {{post}} handlebars helper, for including a post, or a list of posts.
  • handlebars-helper-prettify: {{prettify}} handlebars helper, for formatting ("beautifying") HTML, CSS and JavaScript.
  • handlebars-helper-process: {{process}} handlebars helper, for processing raw templates in included content, with the correct context
  • handlebars-helper-rel: Handlebars helper for generating a relative link from the current page to the specified page.
  • handlebars-helper-repeat: {{repeat}} handlebars helper, for duplicating a block of content n times.
  • handlebars-helper-slugify: Convert strings into URL slugs.
  • handlebars-helper-track: {{track}} handlebars helper. Simplify the process of adding Google analytics tracking codes to your web projects.
  • handlebars-helper-twitter: Add {{tweet}} and {{follow}} buttons using handlebars helpers.
  • handlebars-helper-uml: Embed UML diagrams in your handlebars template using www.websequencediagrams.com
  • lodash-mixin-safename: Get a safe variable name from a given string.
  • logger: Logging utilities for Node.js projects.
  • matchkeys: Return an array of resolved filepaths for specified npm module dependencies. Minimatch patterns can be used.
  • meta: General planning around helpers. Also the place to make requests and suggestions.
  • node-name: Basic utility methods for transforming and handling file paths.
  • sort-object: Sort the keys in an object.
  • strip-yfm: Strip YAML front matter from files.
  • utils: Library of javascript utils
  • utils-compare: Utility compare function, accepts two objects (a,b) and returns 1 if a >= b otherwise -1.
  • utils-concat-array: Takes a string and an array of strings and concatenates the first string to each string in the array.
  • utils-update: Update the properties on an object with the properties from another object.
  • yfm: Helpers and examples for extracting, parsing, and passing context from YAML front matter into your templates. Useful if you need custom programming beyond what Assemble offers by default.

Visit assemble.io/plugins for more information about Assemble plugins.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt, and build the documentation with grunt-readme.

Authors

Jon Schlinkert

Brian Woodward

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by grunt-readme on Wednesday, February 5, 2014.