All Projects → jamen → pixie

jamen / pixie

Licence: MIT license
Tiny template functions.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pixie

dowels
🔨 a tiny but powerful javascript library that performs client-side routing, templating, and REST API communication to help you get your single-page web applications running in seconds
Stars: ✭ 13 (-7.14%)
Mutual labels:  fast, templating, small
elk
A low footprint JavaScript engine for embedded systems
Stars: ✭ 1,458 (+10314.29%)
Mutual labels:  engine, small, tiny
wotpp
A small macro language for producing and manipulating strings.
Stars: ✭ 75 (+435.71%)
Mutual labels:  fast, small
core
🌈 light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
Stars: ✭ 40 (+185.71%)
Mutual labels:  fast, small
Wondercms
WonderCMS - fast and small flat file CMS (5 files)
Stars: ✭ 330 (+2257.14%)
Mutual labels:  fast, small
koa-better-router
❤️ Stable and lovely router for `koa`, using `path-match`. Foundation for building powerful, flexible and RESTful APIs easily.
Stars: ✭ 88 (+528.57%)
Mutual labels:  fast, small
tinypool
🧵 A minimal and tiny Node.js Worker Thread Pool implementation (38KB)
Stars: ✭ 452 (+3128.57%)
Mutual labels:  fast, tiny
wymlp
tiny fast portable real-time deep neural network for regression and classification within 50 LOC.
Stars: ✭ 36 (+157.14%)
Mutual labels:  fast, tiny
Server Manager
This repository holds the IntISP Interface. It can be rebuilt to interface with any other hosting panel.
Stars: ✭ 31 (+121.43%)
Mutual labels:  fast, small
Geotic
Entity Component System library for javascript
Stars: ✭ 97 (+592.86%)
Mutual labels:  fast, engine
Wolff
🐺 Lightweight and easy to use framework for building web apps.
Stars: ✭ 203 (+1350%)
Mutual labels:  fast, small
Librini
Rini is a tiny, non-libc dependant, .ini file parser programmed from scratch in C99.
Stars: ✭ 25 (+78.57%)
Mutual labels:  parse, tiny
Themer
Themer is a colorscheme generator and manager for your desktop.
Stars: ✭ 289 (+1964.29%)
Mutual labels:  parse, templating
core
🚀Fast, 💎Lightweight Angular alternative with the same modern API thats compile directly to WebComponents
Stars: ✭ 49 (+250%)
Mutual labels:  fast, small
desktop
Extendable calculator for the 21st Century ⚡
Stars: ✭ 85 (+507.14%)
Mutual labels:  parse, engine
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 (+371.43%)
Mutual labels:  engine, templating
Bahunya
10KB classless CSS framework with responsive typography, navbar, syntax highlighting, etc.
Stars: ✭ 170 (+1114.29%)
Mutual labels:  small, tiny
Webpack Nano
A teensy, squeaky 🐤 clean Webpack CLI
Stars: ✭ 199 (+1321.43%)
Mutual labels:  small, tiny
Candyview
Implement any RecyclerView in just 1 Line. CandyView handles everything for you.
Stars: ✭ 15 (+7.14%)
Mutual labels:  fast, small
Json
A C++11 or library for parsing and serializing JSON to and from a DOM container in memory.
Stars: ✭ 205 (+1364.29%)
Mutual labels:  fast, parse

pixie

Tiny template engine (422 bytes uglified and gziped)

const { parse, compile } = require('pixie')

const template = parse('foo {{bar}} baz', '{{', '}}')
// => [['foo ', ' baz'], ['bar']]

compile(template, { bar: 'Baaar!' })
// => 'foo Baaar! baz'

Install

npm i pixie

Usage

parse(source, open, close)

Converts a string to a template.

  • source: template string source being parsed
  • open: tag for opening expressions
  • close: tag for closing expressions
// Parse with tags
parse('Hello {{world}} foo {{bar}} baz.', '{{', '}}')

// Parse with alternate tags
parse('Hello <%world%>!', '<%', '%>')

compile(template, data)

Replaces values from an object by key.

  • template: template object that was returned from parse
  • data: object or array to insert into the expressions
var template = parse('foo {{bar}} baz {{qux}}')

compile(template, { bar: 'baaar', qux: 'quuux' })
// 'foo baaar baz quuux'

render(source, data, open, close)

An alternative to doing compile(parse(source, open, close), data), it is slightly faster and creates no intermediate template.

render('Hello, {{world}}!', { world: 'Earth' }, '{{', '}}')
// 'Hello Earth!'

Template structure

Given some template source:

Hello, {{world}}! I am {{person}}.

This is parsed into a template as [fragments, expressions]. The expressions would be ['world', 'person'], and the fragments be the data surrounding the expressions ['Hello, ', '! I am ', '.']. Compilers interpret these to create their output.

Command-line Interface

The package also includes a CLI. It just parses stdin and compiles stdout.

pixie --name "John Doe" < template.src.md > template.md

License

MIT © Jamen Marz

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].