@redaty/lejs
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Lionel Lionel Embedded JavaScript Templates (LeJS)

LeJS Actions Build Status

This repository is dedicated to serving as a platform for practice and training purposes. It should not be used in production environment.

Features

  • Unescaped output with {{ }}
  • IF statement with {# }} {/# ]]
  • Maping objects with {> }} {/> }}

Usage

Node

let template = lejs.compile(str, options);
template(data);
// => Rendered String

lejs.render(str, data, options);
// => Rendered String

lejs.renderFile(filename, data, options);

CLI

.lejs

<p>Hello {{world}}</p>
<ul>
{>li}}
    <li>Index: {{+index}}. {{+value}}</li>
{/>li}}
</ul>
{#details}}
<details>
    {{detail}}
</details>
{/#details}}

JSON data

{
  "world": "World",
  "li": [
    {
      "value": "Line 1"
    },
    {
      "value": "Line 2"
    }
  ],
  "details": true,
  "detail": "This value is visible, because details is true"
}

Output

<p>Hello World</p>
<ul>

    <li>Index: 0. Line 1</li>

    <li>Index: 1. Line 2</li>

</ul>

<details>
    This value is visible, because details is true
</details>

CLI call

node ./dist/bin/cli.js ./test/files/example.lejs -f ./test/files/example.json
# OR
lejs ./test/files/example.lejs -f ./test/files/example.json

Tags

  • {{ }} Value output tag
  • {# }} IF statement start tag
  • {/# }} IF statement end tag
  • {> }} MAP start tag
  • {{+ }} MAP variable tag
  • {/> }} MAP end tag

Readme

Keywords

Package Sidebar

Install

npm i @redaty/lejs

Weekly Downloads

1

Version

1.0.5

License

GPL-3.0

Unpacked Size

67 kB

Total Files

30

Last publish

Collaborators

  • redaty