0.5.3 • Published 3 years ago

smallstache v0.5.3

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Smallstache

Build Status Test Coverage Code Climate

A lightweight, logic-less JavaScript template engine similar to Mustache/Handlebars. And look mummy, it has only 0.5kB minimized!

Features

  • Object-oriented approach
  • Very small footprint
  • No dependencies (only good old VanillaJS)
  • Fast and reliable (100% test coverage)
  • Easily debuggable (leaves original tag if can't find data)

Usage

Typical usage:

  var template = new Smallstache('Hello {{ something }}!');
  template.fill({something: 'World'});
  // > 'Hello World!'

You can also use an array as a data source:

  var title = new Smallstache('{{0}}, {{1}} and {{2}}');
  title.fill(['Me', 'Myself', 'I']);
  // > 'Me, Myself and I'

Or even a string!

  var question = new Smallstache('Food with 5 letters: {{0}}...{{4}}');
  question.fill('kebab');
  // > 'Food with 5 letters: k...b'

More examples of using Smallstache (with node and web browser) you can find in examples directory.

API

  • new Smallstache(string)

    Creates template object from given string.

  • .fill(obj): string

    Returns a string with template filled by an object, an array or a string.

License

MIT

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.6

7 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago