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

mandrill-template-helpers

v1.0.0

Published

mandrill handlebar helper polyfill

Downloads

3

Readme

Mandrill Template Helpers

Mandrill supports a few helpers that are not included with handlebars: upper, lower, title, url, date, striptags & unsub

This acts as a polyfill for those helpers allowing you to build and test your templates locally before publishing

Installation

npm install mandrill-template-helpers --save

Test

npm test

Usage

In your code

var hb = require('handlebars');
var mandrill-helpers = require('mandrill-template-helpers');

hb.registerHelper(mandrill-helpers);

...

var template = hb.compile('./template.html');

in your ./template.html do

    {{#if shout_out}}
        {{upper shout_out}}!
    {{/if}}

if shout_out was hello then it would return HELLO

Inline Helpers Available in Mandrill

From Mandrill...

|Helper | Function | Example| |---|---|---| |upper| uppercase the text provided | {{upper "your text"}} results in: YOUR TEXT | |lower| lowercase the text provided | {{lower "your text"}} results in: your text | |title|title-case the text provided| {{title "your text is neat"}} results in: Your Text is Neat| |url|urlencode the text provided|{{url "http://yourawesomeurl.com"}} results in: http%3A%2F%2Fyourawesomeurl.com| |date|print the current date with a given format, defaults to d/m/Y| {{date "Y-m-d"}} results in: 2015-03-10| |striptags|strip any HTML tags from the given data|{{striptags "<p>your text</p>"}} results in: your text|

Mandrill also offers another helper, {{unsub}} to add an automatic unsubscribe link to your emails. Generally, you would add the unsub helper in handlebars as {{unsub "http://redirecturl.com"}} where you pass the URL directly in the helper and the URL must be enclosed in double quotes. For example:

<a href='{{unsub "http://redirecturl.com"}}'>Unsubscribe</a>

You can also pass the redirect URL as a merge_var:

<a href='{{unsub redirect_merge_var}}'>Unsubscribe</a>

with the merge var defined as:

   "global_merge_vars": [
        {
            "name": "redirect_merge_var",
            "content": "http://yourdomain.com"
        }
    ]

Note: When using the {{unsub}} helper inside of an anchor tag, be sure to use single quotes around for the href='{{unsub }}'.

see: Using-Handlebars-for-Dynamic-Content

Todo

  • implement date helper
  • create placeholder for unsub

LICENCE

MIT