Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/danieldietrich/rich-string

A tag function that automatically aligns embedded multiline strings.
https://github.com/danieldietrich/rich-string

Last synced: about 1 month ago
JSON representation

A tag function that automatically aligns embedded multiline strings.

Awesome Lists containing this project

README

        

[![npm version](https://img.shields.io/npm/v/@danieldietrich/rich-string?logo=npm&style=flat-square)](https://www.npmjs.com/package/@danieldietrich/rich-string/)[![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@danieldietrich/rich-string?style=flat-square)](https://snyk.io/test/npm/@danieldietrich/rich-string)[![minzipped size](https://img.shields.io/bundlephobia/minzip/@danieldietrich/rich-string?style=flat-square)](https://bundlephobia.com/result?p=@danieldietrich/rich-string@latest)
 
[![build](https://img.shields.io/travis/danieldietrich/rich-string?logo=github&style=flat-square)](https://travis-ci.org/danieldietrich/rich-string/)[![coverage](https://img.shields.io/codecov/c/github/danieldietrich/rich-string?style=flat-square)](https://codecov.io/gh/danieldietrich/rich-string/)
 
![Platform](https://img.shields.io/badge/platform-Node%20v10%20+%20Browser%20%28ES6%2fES2015%29-decc47?logo=TypeScript&style=flat-square)
 
[![Sponsor](https://img.shields.io/badge/GitHub-💖Sponsors-b5b7b9?logo=github&style=flat-square)](https://github.com/sponsors/danieldietrich)[![donate](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://paypal.me/danieldietrich13)[![license](https://img.shields.io/github/license/danieldietrich/rich-string?style=flat-square)](https://opensource.org/licenses/MIT/)
 
[![Follow](https://img.shields.io/twitter/follow/danieldietrich?label=Follow&style=social)](https://twitter.com/danieldietrich/)

# rich-string

A tag function that automatically aligns embedded multiline strings.

## Installation

```bash
npm i @danieldietrich/rich-string
```

## Usage

The module supports ES6 _import_ and CommonJS _require_ style.

```ts
import s from '@danieldietrich/rich-string';

/*
function sayHi(name) {
console.log('Hi ${name}, I hope you are doing well!');
}
*/
const res = generateSayHi(s`

console.log('Hi \${name}, I hope you are doing well!');

`);

function generateSayHi(body: string): string {
return s`
function sayHi(name) {
${body}
}
`;
}
```

---

Copyright © 2020 by [Daniel Dietrich]([email protected]). Released under the [MIT](https://opensource.org/licenses/MIT/) license.