1.0.7 • Published 3 years ago

platevia v1.0.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

PlateVia for Javascript

A javascript parser to parse Template or Expression, based on AST.

Install

npm install -D platevia

CLI

npx platevia -v # Get current version
npx platevia -h # Get the cli help text

Demo

Parse Expression

const { parsePlate } = require('platevia');

const toParseText = '1 + a'

const parsedResult = parsePlate(toParseText).via({a: 100})

console.log(parsedResult); // > 101

Parse Template

In fact, the expression is being parsed, but the template string based on ES6 is replaced

const { parsePlate } = require('platevia');

const toParseText = '`Hello ${ yourName }, there are ${ clients.length } clients: ${ each(clients, client => client.name, \', \') }`'

const parsedResult = parsePlate(toParseText).via(
    {
        yourName: 'Weals',
        clients: [
            {
                name: 'Ane'
            },
            {
                name: 'Lee'
            },
            {
                name: 'Joe'
            }
        ],
        each: function(array, each, separator){
            return array.map(each).join(separator);
        }
    }
)

console.log(parsedResult); // > Hello Weals, there are 3 clients: Ane, Lee, Joe

API Documentation

https://github.com/canguser/platevia/blob/master/docs/modules.md

1.0.2

3 years ago

1.0.1

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.0

3 years ago