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 🙏

© 2025 – Pkg Stats / Ryan Hefner

persoo-templates

v1.1.1

Published

Templates for persoo widgets.

Readme

persoo-templates

Templates for Persoo widgets (in page web parts, emails,...)

Installation

npm install persoo-templates

Usage

Include js library in your code. Then you can render "persoo templates" by calling persooTemplates.render() and providing widget instance (content and configuration for each template) and context (global settings related to each customer, i.e. recommended products to be rendered).

    var persooTemplates = require('persoo-templates');

    var templateString = "Master template using predefined field as EJS variables, i.e. <%= fieldID %>";    
    var offerContentInstance = {
        templateID: 'templateID1',
        content: {
            fieldID: 'myFieldValue'
        },
        scenarios: [
            {id: 'products1', scenarioID: 'sampleScenarioID'}
        ]
    };
    var context = {};

    var renderedHTML = persooTemplates.render(templateString, offerContentInstance, context);

Output for the example above should be Master template using predefined field as EJS variables, i.e. myFieldValue

See unit tests for more examples.

Note: in Persoo, each offer contains possible variants for AB testing. Thus inside Persoo, there is

var offer = {
    variants: [
        offerContentInstance,
        ...
    ]
}

thus Persoo developers calls

var renderedHTML = persooTemplates.render(templateString, offer.variants[0], context);

Note: Fields passed in context are rendered as well, except for fields, whose name ends with 'Template' suffix. I.e. ItemTemplate: "<%= abc %>" will be kept as it is. It's usefull for adding template strings to Widget configurations.

Tests

npm test

Preview Editor for debugging

For easy templates debuging and unit testing, you can use JSON editor with widget preview. Run npm run build and then open /editor/preview.html in your browser.

Note: Use local webserver to access the html file through http:// protocol. Note: Chrome does not allow to load JSON file with templates through file:// protocol. Thus if you cannot access preview.html through http:// protocol (from local webserver), try to start Chrome with allowed access to local files (generally it is not permitted because of security reasons). On Windows run chrome.exe --allow-file-access-from-files On Mac run open /Applications/Google\ Chrome.app/ --args --allow-file-access-from-files

Basic Persoo templates

We also provide a few basic templates for Persoo offers. You can use them as inspiration for creating your own persoo templates. They are located in template directory. See persoo templates developer guide for more information.

To build all templates run

 npm run build:templates

or

 npm run watch:templates

if you want to rebuild templates automatically. Build script will ouput JSON with all templates to build/templates.json and separate JSONs for each template to build/templates/<templateID>.json.

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.