项目作者: macie

项目描述 :
Lightweight JavaScript template engine.
高级语言: JavaScript
项目地址: git://github.com/macie/smallstache.git
创建时间: 2016-09-30T16:15:09Z
项目社区:https://github.com/macie/smallstache

开源协议:MIT License

下载


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:

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

You can also use an array as a data source:

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

Or even a string!

  1. var question = new Smallstache('Food with 5 letters: {{0}}...{{4}}');
  2. question.fill('kebab');
  3. // > '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