Skip to content

iansinnott/trimstring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trimstring

Build Status trimstring on NPM

🔪 Neatly trim template strings

Install

$ npm install --save trimstring

Usage

const trimstring = require('trimstring');

const genHtml = props => {
  return trimstring(`
    <!doctype html>
    <html lang='en'>
      <head>
        <meta charset='utf-8'>
        <title>${props.title}</title>
      </head>
      <body>
        ${props.body}
      </body>
    </html>
  `);
};

// Leading whitespace and trailing newlines will be trimmed.
genHtml({ title: 'Trimstring', body: 'This is my favorite library!' }); //=>
`<!doctype html>
<html lang='en'>
  <head>
    <meta charset='utf-8'>
    <title>Trimstring</title>
  </head>
  <body>
    This is my favorite library!
  </body>
</html>`

API

trimstring(templateString)

templateString

Type: string

A multiline string for trimming.

NOTE: If your string does not need multiple lines then trimstring probably won't help you. The core use of this library is for creating strings without leading whitespace or trailing/leading newlines but allowing you to still write your code in a readable way.

License

MIT © Ian Sinnott

About

🔪 Neatly trim template strings

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published