An open API service indexing awesome lists of open source software.

https://github.com/iansinnott/trimstring

🔪 Neatly trim template strings
https://github.com/iansinnott/trimstring

string template trim

Last synced: about 1 month ago
JSON representation

🔪 Neatly trim template strings

Awesome Lists containing this project

README

          

# trimstring

[![Build Status](https://img.shields.io/circleci/project/iansinnott/trimstring.svg)](https://circleci.com/gh/iansinnott/trimstring)
[![trimstring on NPM](https://img.shields.io/npm/v/trimstring.svg)](https://www.npmjs.com/package/trimstring)

> 🔪 Neatly trim template strings

## Install

```
$ npm install --save trimstring
```

## Usage

```js
const trimstring = require('trimstring');

const genHtml = props => {
return trimstring(`




${props.title}


${props.body}


`);
};

// Leading whitespace and trailing newlines will be trimmed.
genHtml({ title: 'Trimstring', body: 'This is my favorite library!' }); //=>
`



Trimstring


This is my favorite library!

`
```

## 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](http://iansinnott.com)