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

tpltonpeck

v1.0.3

Published

Light Template Engine

Downloads

6

Readme

TpltonPeck

Light Template Engine - Templeton "Faceman" Peck

Based on the famous character name from ATeam Serie from the 80's, Templeton "Faceman" Peck, here is a light template engine based on a short configuration and easy to modelise architecture (usefull for emails).

Release note

1.0.3 - 09/26/2019 - Remove first argument on readFile function to avoid complicated configuration

Architecture

To use TpltonPeck, you must follow a certain architecture :

/<src>
  /chuncks
    /<type>
      /file.<type>
  /partials
    /<type>
      /file.<type>
  /file.<type>

Explanations :

  • src is the folder you want to store your templates
  • You must have a file.< type > where type is the type of your file (html, text, yaml...), you can set this value to raw to use raw text instead of a file template.

Configuration

For each template, you must set a configuration.

rootURL {String} Mandatory : it's the main url for your templates folder. Can be relative.

main {String} Mandatory : The main template file, or, the content to format, if type is set to raw

type {String} Mandatory : This value depends of your template files. You can use either html, text, or all other file format you want to use. You can use raw to not use file, but use main as the text to format.

texts {Object} Mandatory : This value is an Object combining key/values. For each key inside the template, it will be replaced by its value. Use % symbol around your variable name inside your template to use it as a template variable.

%title%
%date%
%content%
%amountValue%
%policyholder_firstName%
const configuration = {
  ...
  texts: {
    key: "Here is a key that will not be %processed%"
  }
}

In the example above, %processed% will not be processed.

partials {Array} Optional : Partials are chunck of data you want to implement inside your main file.

Be aware that you can't put a partial inside an another partial.

Just put the partial file, inside your partials/<type>/ directory with the proper <type> file extention.

You can add as many as you want texts variables inside a partial.

You must use the following notation inside your main template to specify to the template engine that you use a partial %partial__...% :

<section>
  <section role="main">
    %partial__content%
  </section>
  <footer>
    %partial__footer%
  </footer>
</section>

You must prefix the name of your partial with partial__, and, as for the texts variable, add % around the variable name.

%partial__< partialName >%

chuncks {Array} Optional :

Here is a html example

const configuration = {
  rootURL: './templates',
  main: 'index',
  type: 'html',
  texts: {
    title: 'Page title',
    pageContent: 'Lorem Ipsum est dolor\nsit Amet est.'
  },
  partials: ['header', 'footer'],
  chuncks: [
    {
      name: 'chunckName',
      values: [
        {
          key: 'value'
        }
      ]
    }
  ]
};

Here is a text example

const configuration = {
  rootURL: './templates',
  main: 'index',
  type: 'text',
  texts: {
    title: 'Page title',
    pageContent: 'Lorem Ipsum est dolor\nsit Amet est.'
  }
};

Here is a raw example

const configuration = {
  rootURL: './templates',
  main: 'Links awakening on Nintendo Switch will be release on %date%',
  type: 'raw',
  texts: {
    date: 'September 20, 2019'
  }
};

How to use

Tests