Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tempura

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tempura

WIP

  • 0.1.0-next.2
  • next
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-4.56%
Maintainers
1
Weekly downloads
 
Created
Source
tempura
version CI codecov downloads
A light, crispy, and delicious template engine 🍤

Features

  • Extremely lightweight
    Everything is 1.25 kB (gzip) – even less with tree-shaking!

  • Super Performant
    Significantly faster than the big names; and the small ones.

  • Familiar Syntax
    Tempura templates look great with Handlebars syntax highlighting.

  • Custom Directives
    Easily define custom directives, via the API, to extend functionality.

Install

$ npm install --save tempura

Usage

// TODO

Syntax

TODO

API

Note: All methods share common Options.

tempura.compile(input, options?)

Returns: (data: object) => string

Convert a template into an executable function equivalent.

This function will produce a string output based on the data you provide. The data key names should match the #expected variable names.

input

Type: string

The template to be converted.

options.escape

Type: (value: any) => string

todo

tempura.transform(input, options?)

Returns: string

Transforms the input source template into JavaScript code. Unlike tempura.compile(), this generates a string instead of a function, which means that this method is likely only suitable for generating and/or replacing code at build-time.

input

Type: string

The template to be converted.

options.format

Type: "esm" or "cjs"
Default: "esm"

Modify the generated output to be compliant with the CommonJS or ES Module format.

Note: Most bundlers and/or upstream consumers can understand (and prefer) the ESM format.

Options

options.props

Type: string[]

The names of variables that will be provided to a view.

NOTE: Declaring options.props names could take the place of {{#expect ...}} declarataions – and vice versa. In other words, options.props is a programmatic way to define (or skip) {{#expect}} blocks. Declaring a variable name in both locations has no effect.

options.blocks

Type: { ... }

TODO: extra actions/blocks

Benchmarks

Running via Node v14.15.13

Please visit the /bench directory for complete, reproducible benchmarks.

The following is a subset of the full results, presented without context. Again, please visit /bench for explanations and/or comparisons.

Benchmark: Render w/ raw values (no escape)
  pug                x 34,847 ops/sec ±2.79% (93 runs sampled)
  handlebars         x  6,700 ops/sec ±1.41% (92 runs sampled)
  ejs                x    802 ops/sec ±0.54% (94 runs sampled)
  dot                x 40,704 ops/sec ±3.08% (93 runs sampled)
  art-template       x 39,839 ops/sec ±0.86% (90 runs sampled)
  tempura            x 44,656 ops/sec ±0.42% (92 runs sampled)

Benchmark: Render w/ escaped values
  pug                x 2,800 ops/sec ±0.31% (95 runs sampled)
  handlebars         x   733 ops/sec ±0.34% (94 runs sampled)
  ejs                x   376 ops/sec ±0.17% (91 runs sampled)
  dot                x   707 ops/sec ±0.15% (96 runs sampled)
  art-template       x 2,707 ops/sec ±0.12% (96 runs sampled)
  tempura            x 2,922 ops/sec ±0.31% (96 runs sampled)

License

MIT © Luke Edwards

FAQs

Package last updated on 10 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc