Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/wbhob/magique

A utility for wrapping strings in tags without the headache.
https://github.com/wbhob/magique

dom html javascript magique tags typescript

Last synced: 8 days ago
JSON representation

A utility for wrapping strings in tags without the headache.

Awesome Lists containing this project

README

        

# Magique
Magique is a dead-simple, highly-readable way to write HTML in JavaScript. It's particularly designed for templating, so if you find yourself writing a lot of wrapping tags (like `` and ``) around strings, you'll find this package useful.

## Example
```ts
import { b, i } from 'magique';

b('hello') // yields hello
i('hello') // yields hello
```

## Installation
```sh
$ npm install --save magique
```

## Usage
### TypeScript/ES6
```ts
import { bold } from 'magique';
bold('hello');

/* OR */

import * as magique from 'magique';
magique.bold('hello');
```

### ES5
```js
var magique = require('magique');
magique.bold('hello');

/* OR */

var bold = require('magique').bold;
bold('hello');
```

## Supported Tags and Aliases
| Tag | Aliases | Returns | Usage |
| ---------------------------------- | ---------------- | ---------------------------------------- | ---------------------------------------------- |
| `b` | `bold`, `strong` | `str` | `b(str)` |
| `i` | `italic`, `em` | `str` | `i(str)` |
| `a` | `link` | `str` or `str` | `a(str)` OR `a(str, href)` |
| `br` | `N/A` | `
` | `br()` |
| `hX` | `header` | `str` | `h(level)(str)` where level is between 1 and 6 |
| `h1`, `h2`, `h3`, `h4`, `h5`, `h6` | `N/A` | `

str

` | `h1(str)` |