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

quickplate-template

v1.0.5

Published

A powerful HTML templating library for generating dynamic HTML from templates

Readme

QuickPlate Template Library

QuickPlate Template Library is a flexible HTML templating solution that allows developers to create dynamic HTML from templates using placeholder replacement, loops, and conditional sections. The library is designed to work with generic templates regardless of their structure, making it ideal for use in applications where the template format is unknown ahead of time.

Installation

npm install quickplate-template

Note: The package is published as quickplate-template due to npm naming requirements, but contains all the powerful QuickPlate templating features.

Alternative installation methods:

Via yarn:

yarn add quickplate-template

Direct from GitHub:

npm install git+https://github.com/labKnowledge/quickplate.git

Features

  • Generic Template Support: Works with any HTML template structure
  • Placeholder Replacement: Replace {key} placeholders with data values
  • Loop Processing: Process arrays with {LOOP_START:name}...{LOOP_END:name} syntax
  • Conditional Sections: Automatically remove empty sections based on data availability
  • Special Field Processing: Enhanced handling for specific fields like stars and addContact
  • Layout Reordering: Dynamically reorder template sections using <!-- BLOCK:name -->...<!-- ENDBLOCK:name --> and layoutOrder data property
  • Block Swapping: Swap template blocks with {SWAP:block1:block2} directive or swaps data property
  • HTML-to-Template Conversion: Generate templates and expected data structures from existing HTML (generateTemplateFromHtml)
  • Advanced Export Options: Convert processed templates to multiple formats (HTML, Markdown, Text, AST for component conversion)
  • AST Export: Get Abstract Syntax Tree representation for easy conversion to React/Next.js components or PDF formats
  • React Integration Ready: AST format makes conversion to React components straightforward
  • @react-pdf/renderer Compatible: AST structure can be mapped to PDF components
  • Automatic HTML Escaping: Prevents XSS vulnerabilities
  • Configurable: Customize behavior with options
  • TypeScript Support: Full TypeScript definitions included

Installation

npm install quickplate-template

Quick Start

import { TemplateProcessor } from 'quickplate-template';

// Create a processor instance
const processor = new TemplateProcessor();

// Define your template with placeholders
const template = `
  <div class="profile">
    <h1>{firstName} {lastName}</h1>
    <p>Email: {email}</p>
  
    <!-- Reviews section -->
    <div class="reviews">
      {LOOP_START:reviews}
        <div class="review">
          <h3>{name}</h3>
          <div class="stars">{stars}</div>
          <p>{comment}</p>
        </div>
      {LOOP_END:reviews}
    </div>
    <!-- EndReviews section -->
  </div>
`;

// Define the data
const data = {
  firstName: 'John',
  lastName: 'Doe',
  email: '[email protected]',
  reviews: [
    { name: 'Jane Smith', stars: 5, comment: 'Great service!' },
    { name: 'Bob Johnson', stars: 4, comment: 'Professional work.' }
  ]
};

// Process the template
const result = processor.process(template, data);
console.log(result);

Documentation

For complete documentation, visit:

Special Field Processing

The library provides special handling for specific fields:

stars

Converts numeric values to 5-star rating display:

  • {stars: 4} becomes ★★★★☆
  • {stars: 2} becomes ★★☆☆☆

addContact

Automatically adds vCard prefix for contact information:

  • {addContact: 'VCARD_DATA'} becomes data:text/vcard;charset=utf-8,ENCODED_VCARD_DATA

Compatibility

  • Node.js v12 or higher
  • Works with both JavaScript and TypeScript
  • Browser environments (with bundler)

Contributing

We welcome contributions! Please see our Contributing Guidelines for more details.

License

MIT