New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tljs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tljs

[![Travis](https://img.shields.io/travis/theJian/tljs.svg?style=flat-square)](https://travis-ci.org/theJian/tljs.svg?branch=master)

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

tljs

Travis

Tiny template engine powered by es6 template literals

  • Super small (< 30 lines).
  • Pure JavaScript syntax.
  • Template includes

Install

npm install tljs

Usage

import tl from 'tljs';

// template
const t = tl`
<div>
${' if (username) { '}
  <p>${' echo(username) '}</p>
${' } '}
</div>`;

// render
t({ username: 'theJian' });

  
// output
<div>

  <p>theJian</p>
  
</div>


/////////////////////////// Generate JSON ////////////////////////////////

const jsonTl = tl`
{
  username: ${' echo(username) '}
}`;

jsonTl({ username: 'theJian' });

API

Echo

Instead of defining some fancy syntax for inserting variables to the output, echo, a good old JavaScript function, has provided to handle this job.

`Here is the ${' echo(username) '}`

Include

To insert contents from another file.

<div>
${' include("./header.js", { title: title }) '}
${' posts.forEach(post => { '}
  <p>
  ${ 'include("./post.js", { post: post }) '}
  </p>
${' } '}
</div>

To use this feature you have to pass a require function when rendering. See Example. The first argument is the path of included file, the second is the values passed to it.

License

MIT@theJian

FAQs

Package last updated on 28 Mar 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