All Projects → luwes → hyperstache

luwes / hyperstache

Licence: other
👨‍🦰 Handlebars just got a trim, alternative JS template engine, 2kb gzip

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hyperstache

Ramhorns
Fast Mustache template engine implementation in pure Rust.
Stars: ✭ 172 (+377.78%)
Mutual labels:  mustache, handlebars
Handlebars
Fullest Handlebars.js templating support for Atom and Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://atom.io/packages/Handlebars and https://packagecontrol.io/packages/Handlebars.
Stars: ✭ 292 (+711.11%)
Mutual labels:  mustache, handlebars
rollup-plugin-tagged-template
Use plain HTML files as tagged templates.
Stars: ✭ 24 (-33.33%)
Mutual labels:  template-literals, tagged-template
Lightncandy
An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ),
Stars: ✭ 565 (+1469.44%)
Mutual labels:  mustache, handlebars
HandlebarsCookbook
A cookbook of handlebars and mustache, focus on handlebars.js , mustache.js and lightncandy usage
Stars: ✭ 20 (-44.44%)
Mutual labels:  mustache, handlebars
Handlebars.net
A real .NET Handlebars engine
Stars: ✭ 723 (+1908.33%)
Mutual labels:  mustache, handlebars
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+797.22%)
Mutual labels:  mustache, handlebars
Scriban
A fast, powerful, safe and lightweight scripting language and engine for .NET
Stars: ✭ 1,360 (+3677.78%)
Mutual labels:  mustache, handlebars
Gluebert
gluebert.js is a tiny helper lazy loading DOM Elements, StyleSheets and JavaScript files using dynamic import and code splitting
Stars: ✭ 194 (+438.89%)
Mutual labels:  mustache, handlebars
samples
A collection of sample dashboards, custom labels, mustaches, SQL scripts and PowerShell scripts to help you get the most out of SquaredUp. #community-powered
Stars: ✭ 17 (-52.78%)
Mutual labels:  mustache
awesome-tagged-templates
A list of libraries and learning resources for ES2015 tagged template literals
Stars: ✭ 79 (+119.44%)
Mutual labels:  template-literals
vim-ember-hbs
Ember Handlebars/HTMLBars plugin for Vim with indentation support
Stars: ✭ 45 (+25%)
Mutual labels:  handlebars
modulor-html
Missing template engine for Web Components
Stars: ✭ 36 (+0%)
Mutual labels:  template-literals
dc-accelerators-content-rendering-service
An accelerated starting point for implementing Amplience Dynamic Content.
Stars: ✭ 15 (-58.33%)
Mutual labels:  handlebars
ocaml-mustache
mustache.js logic-less templates in OCaml
Stars: ✭ 74 (+105.56%)
Mutual labels:  mustache
option chain analysis
NSE Nifty Option chain analysis on the web page.
Stars: ✭ 63 (+75%)
Mutual labels:  handlebars
handlebars.c
C implementation of handlebars.js
Stars: ✭ 31 (-13.89%)
Mutual labels:  handlebars
php-mustache
Mustache PHP Extension
Stars: ✭ 55 (+52.78%)
Mutual labels:  mustache
nodejs-shopping-cart
NodeJS / Express / MongoDB - Shopping Cart (monolithic app with handlebars)
Stars: ✭ 42 (+16.67%)
Mutual labels:  handlebars
Cybros-Web-Application
Cybros Web Application Development
Stars: ✭ 29 (-19.44%)
Mutual labels:  handlebars

Hyperstache

Build Status Badge size codecov code style: prettier

Logic-less templates to template literals transformer.
Hyperstache includes a full parser and runtime.
It uses no eval and minimal regex for the best performance.
It's largely compatible with Handlebars and Mustache templates.

npm: npm install hyperstache --save
cdn: https://unpkg.com/hyperstache
module: https://unpkg.com/hyperstache?module

Why?

The goal is to make projects invested in Handlebars templates adopt a tagged templates only solution easily or add an additional layer of logic-less templates on top of any tagged template library.

hyperstache by the numbers:

🚙 2.07kB when used directly in the browser

🏍 1.74kB hyperstache/mini version (built-in helpers)

🏎 1.07kB if compiled using babel-plugin-hyperstache

Features

  • variables {{escaped}}, {{{unescaped}}}
  • variables dot notation {{obj.prop}}
  • helpers {{loud lastname}}
  • helpers literal arguments: numbers, strings, true, false, null and undefined
  • basic block helpers {{#bold}}
  • built-in helpers: if, unless, each, with
  • helper hash arguments
  • comments {{!comment}}, {{!-- comment with }} --}}
  • whitespace control {{~ trimStart }}
  • helper block parameters
  • subexpressions
  • partials {{>partial}}

Usage (CodeSandbox)

import { compile } from "hyperstache";

const o = (...args) => args;
const template = compile.bind(o)`
  <p>
    Hello, my name is {{name}}. 
    I am from {{hometown}}. I have {{kids.length}} kids:
  </p>
  <ul>
    {{#each kids}}
      <li>{{name}} is {{age}}</li>
    {{/kids}}
  </ul>
`;

const data = {
  name: "Alan",
  hometown: "Somewhere, TX",
  kids: [{ name: "Jimmy", age: "12" }, { name: "Sally", age: "4" }]
};
console.log(template(data));

/** =>
[
  [
    "<p>↵    Hello, my name is ",
    ". ↵    I am from ",
    ". I have ",
    " kids:↵  </p>↵  <ul>",
    "</ul>"
  ],
  "Alan",
  "Somewhere, TX",
  2,
  [
    ["", "", ""],
    [
      ["<li>", " is ", "</li>"],
      "Jimmy",
      "12"
    ],
    [
      ["<li>", " is ", "</li>"],
      "Sally",
      "4"
    ]
  ]
]
 */

API

compile(statics, ...exprs)

registerHelper(name, fn)

escapeExpression(str)

new SafeString(htmlStr)

Real world (CodeSandbox)

import { html } from "sinuous";
import { compile } from "hyperstache";

const template = compile.bind(html)`
  <p>
    Hello, my name is {{name}}. 
    I am from {{hometown}}. I have {{kids.length}} kids:
  </p>
  <ul>
    {{#each kids}}
      <li>{{name}} is {{age}}</li>
    {{/kids}}
  </ul>
`;

const data = {
  name: "Alan",
  hometown: "Somewhere, TX",
  kids: [{ name: "Jimmy", age: "12" }, { name: "Sally", age: "4" }]
};
const dom = template(data);
document.body.append(dom);
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].