All Projects → sindresorhus → Pupa

sindresorhus / Pupa

Licence: mit
Simple micro templating

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pupa

engine
A pragmatic approach to templating for PHP 7.x+
Stars: ✭ 31 (-86.58%)
Mutual labels:  template-engine, templating
Squirrelly
Semi-embedded JS template engine that supports helpers, filters, partials, and template inheritance. 4KB minzipped, written in TypeScript ⛺
Stars: ✭ 359 (+55.41%)
Mutual labels:  npm-package, template-engine
view
Template Engine For AdonisJS
Stars: ✭ 13 (-94.37%)
Mutual labels:  template-engine, templating
dry
Dry is a new template engine and language, and is a superset of Shopify's Liquid, with first-class support for advanced inheritance features, and more. From the creators of Enquirer, Assemble, Remarkable, and Micromatch.
Stars: ✭ 66 (-71.43%)
Mutual labels:  template-engine, templating
Metalsmith React Templates
A metalsmith plugin to render files using React / Preact / JSX based templates.
Stars: ✭ 90 (-61.04%)
Mutual labels:  templating, template-engine
hydrate-text
A small, dependency-free and strongly typed template engine.
Stars: ✭ 45 (-80.52%)
Mutual labels:  template-engine, string
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+39.83%)
Mutual labels:  templating, template-engine
safe-string-interpolation
A type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs !
Stars: ✭ 14 (-93.94%)
Mutual labels:  string, interpolation
Better Strings
Java String Interpolation Plugin
Stars: ✭ 66 (-71.43%)
Mutual labels:  string, interpolation
Awesome Twig
A curated list of amazingly awesome Twig extensions, snippets and tutorials
Stars: ✭ 63 (-72.73%)
Mutual labels:  templating, template-engine
morestachio
Lightweight, powerful, flavorful, template engine.
Stars: ✭ 45 (-80.52%)
Mutual labels:  template-engine, templating
Jxls
Java library for creating Excel reports using Excel templates
Stars: ✭ 128 (-44.59%)
Mutual labels:  templating, template-engine
comment-mark
Interpolate strings with HTML comment markers!
Stars: ✭ 21 (-90.91%)
Mutual labels:  string, interpolation
split-on-first
Split a string on the first occurrence of a given separator
Stars: ✭ 68 (-70.56%)
Mutual labels:  string, npm-package
express-edge
🔤  Use Edge templating engine with Express
Stars: ✭ 45 (-80.52%)
Mutual labels:  template-engine, templating
Microwebsrv
A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
Stars: ✭ 420 (+81.82%)
Mutual labels:  templating, template-engine
Tempy
Python Object Oriented Html Templating System
Stars: ✭ 126 (-45.45%)
Mutual labels:  templating, template-engine
Phptal
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
Stars: ✭ 155 (-32.9%)
Mutual labels:  templating, template-engine
Hypertextliteral
Generate HTML, XML, and other web content using Swift string literal interpolation
Stars: ✭ 219 (-5.19%)
Mutual labels:  interpolation
Ragtextfield
Subclass of UITextField that adds an animated placeholder and an optional hint label below the text.
Stars: ✭ 227 (-1.73%)
Mutual labels:  placeholder

pupa

Simple micro templating

Useful when all you need is to fill in some placeholders.

Install

$ npm install pupa

Usage

const pupa = require('pupa');

pupa('The mobile number of {name} is {phone.mobile}', {
	name: 'Sindre',
	phone: {
		mobile: '609 24 363'
	}
});
//=> 'The mobile number of Sindre is 609 24 363'

pupa('I like {0} and {1}', ['🦄', '🐮']);
//=> 'I like 🦄 and 🐮'

// Double braces encodes the HTML entities to avoid code injection
pupa('I like {{0}} and {{1}}', ['<br>🦄</br>', '<i>🐮</i>']);
//=> 'I like &lt;br&gt;🦄&lt;/br&gt; and &lt;i&gt;🐮&lt;/i&gt;'

API

pupa(template, data)

template

Type: string

Text with placeholders for data properties.

data

Type: object | unknown[]

Data to interpolate into template.

FAQ

What about template literals?

Template literals expand on creation. This module expands the template on execution, which can be useful if either or both template and data are lazily created or user-supplied.

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].