npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

striate

1.0.0 • Public • Published

striate

npm version Build Status

striate is a thin wrapper for ejs that is smart about line breaks, so you don't have to worry so much about delimiter placement.

Install

$ npm install --save striate

Usage

striate uses >> at the beginning of a line as the delimiter.

The entire line will be excluded from the output.

var striate = require('striate')
 
var input = 
`var a = 10;
 
>> if(b) {
var b = 20;
>> }
 
var c = 30;`
 
var output1 = striate(input, { b: true })
/*
var a = 10;
 
var b = 20;
 
var c = 30;
*/
 
var output2 = striate(input, { b: false })
/*
var a = 10;
 
var c = 30;
*/

API:

var output = striate(input, data, options)

  • input - The input template (string)
  • data - The data to be injected into the template (object)
  • options - Options that are passed along to ejs (object)

Options:

{
  // By default striate takes data and renders your template using ejs.
  // Set to false to output an unrendered ejs template instead.
  render: true,
  
  // If you prefer to indent all lines of code between >> delimeters without
  // it affecting the output, set this to true.
  indent: false
}

Under the hood

striate transforms templates directly into ejs, but with whitespace placed correctly near delimiters.

var a = 10;
 
>> if(b) {
var b = 20;
>> }
 
var c = 30;

is exactly the same as the following ejs code:

var a = 10;
 
<% if(b) {
%>var b = 20;
<% }
%>
var c = 30;

Note: striate's functionality is similar to slurp syntax <%_ ... _%> introduced in ejs, but better for nested indentation.

License

ISC © Raine Lourie

install

npm i striate

Downloadsweekly downloads

3

version

1.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability