rockplate
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

MIT License Build Status codecov.io Code Coverage dependencies Status devDependencies Status HitCount

Rockplate

Templating language for sensible humans

Rockplate Demo

Documentation and Demo

Click here for full documentation with demo and examples.

Quick Docs for the curious cats

Installation

npm install rockplate

Usage

TypeScript/JavaScript

import { Rockplate } from 'rockplate';
 
const template = 'My name is [my name]';
const schema = {
  my: {
    name: 'My Name',
  },
};
const rpl = new Rockplate(template, schema);
const output = rpl.parse({
  // you will get type hints
  // for properties in schema as you type
  my: {
    name: 'Safraz Razik',
  },
});
console.log(output); // My name is Safraz Razik

Syntax and Schema/Data structure

Limitations are good - for a templating language

Booleans

Values: true | false

{
  "order" : {
    "paid": true
  },
  "vegetables": {
    "fresh": true // example for " are " operator
  }
 
}

Syntax: [if order is paid] .... [end if]

Operators: is | are | is not | are not

[if order is paid]
  Paid
[else]
  Unpaid
[end if]
I eat
[if vegetables are fresh]
  healthy
[end if]
vegetables 🥕🥦🍅🍆🥝🥬🥒🌶

Identifers

Values: string | number or any printable value

{
  "order" : {
    "ref": "210045-674558-981560"
  }
}

Syntax: [order ref]

Thank you for your order [order ref]

Arrays

Value: Collection of Booleans or Identifers

{
  "orders" : [
    {
      "order" : {
        "status": "Paid",
        "ref": "210045-674558-981560"
      },
      "discount" : {
        "available": false,
        "amount": "5%"
      }
    }
  ]
}

Syntax: [repeat orders] .... [end repeat]

Your orders:
[repeat orders]
 
 Ref: [order ref]
 
 Status: [order status]
 
 [if discount is available]
   Discount: [discount amount]
 [end if]
 
[end repeat]

Readme

Keywords

none

Package Sidebar

Install

npm i rockplate

Weekly Downloads

8

Version

1.0.0

License

MIT

Unpacked Size

369 kB

Total Files

67

Last publish

Collaborators

  • safrazik