Socket
Book a DemoInstallSign in
Socket

crouch

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crouch

Micro JS templating engine

0.1.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

crouch

NPM

Crouch is a micro JS template engine. I created this because I had a need for supersmall and lightweight module which would replace some strings inside templates. Templates were as strings like Hello, my name is {name}. I'm from {city}. or as HTML like <p class="{className}">{paragraphContent}</p>.

So I created crouch. It can replace placeholders formated as {number|string} in example {0} {1} {hello} {World}.

Installation

The module is intended to be used in browsers as well as in Node.js

Using npm:

npm install --save crouch

In browser get the code https://github.com/hendrysadrak/crouch/tree/master/dist or:

<script src="https://cdn.rawgit.com/hendrysadrak/crouch/master/dist/crouch.js"></script>

Try

You can try crouch in action here on Tonicdev

Using Crouch with html templates

Usage

'use strict';

var crouch = require('crouch');

// or if es6
import crouch from 'crouch';

Using values as array:

var
    template = 'Hello, my name is {0}. I\'m from {1}.',
    values   = [ 'James', 'Chicago' ];


var output = crouch( template, values );


console.log( output );
// Hello, my name is James. I'm from Chicago.

Using values as object:

var
    template = 'Hello, my name is {name}. I\'m from {city}.',
    values   = { name: 'James', city: 'Chicago' };


var output = crouch( template, values );


console.log( output );
// Hello, my name is James. I'm from Chicago.

Developing

npm i
npm run build

Todo

  • Add support for getter/setter functions
  • Add support for loops
  • Add support for if/elseif/else

License

MIT

Keywords

templating

FAQs

Package last updated on 08 Jun 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.