# tagged-replace

> Javascript text replacement searching for tags.

Latest version **1.0.0** (published 2016-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install tagged-replace
pnpm add tagged-replace
yarn add tagged-replace
bun add tagged-replace
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-16 |
| First published | 2016-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Javier Cardona |
| Maintainers | javver |
| Keywords | utility, text, replace, comments, tags |

## Links

- npm: https://www.npmjs.com/package/tagged-replace
- Repository: https://github.com/javver/tagged-replace
- Homepage: https://github.com/javver/tagged-replace#readme
- Issues: https://github.com/javver/tagged-replace/issues
- npm.io page: https://npm.io/package/tagged-replace

## Dependencies (1)

- [lodash.defaults](https://npm.io/package/lodash.defaults.md) ^4.0.1

## Recent versions

- 1.0.0 (latest) — 2016-03-16

## README

# tagged-replace

[![Build Status](https://travis-ci.org/javver/tagged-replace.svg?branch=master)](https://travis-ci.org/javver/tagged-replace)
[![Coverage Status](https://coveralls.io/repos/github/javver/tagged-replace/badge.svg?branch=master)](https://coveralls.io/github/javver/tagged-replace?branch=master)

Replace pieces of your source using comment tags to identify the location.

## Usage

```js
/* configuration.js */

var myServer = /*host*/ '' /*/host*/;
```

```js
var fs = require('fs');
var taggedReplace = require('tagged-replace');

var content = fs.readFileSync('./configuration.js');
console.log( taggedReplace( content, { host: '\'myhost.example.com\'' } ) );
```

```js
/* console */

var myServer = /*host*/ 'myhost.example.com' /*/host*/;
```

`taggedReplace(contents[, values[, options]])`

#### `contents`

`contents` is the string which may contains some tags

#### `values`

`values` is an object where each key is the name of a tag and its value will be replaced, as a string in the characters between the starting and ending tag.

#### `options`

`options` is an object with overrides for the default parameters described below.

## Configuration

### Tag characters

#### startPrefix

The beginning of the start tag. Defaults to '/*'.

#### startSuffix

The ending of the start tag. Defaults to '*/'.

#### endPrefix

The beginning of the end tag. Defaults to '/*/'.

#### endSuffix

The ending of the end tag. Defaults to '*/'.

### Result padding

#### space

Set to `true` to keep the contents separated from the tags by a space. Defaults to `true`.

The default options are:

```js
defaultOptions = {
   startPrefix: '/*',
   startSuffix: '*/',
   endPrefix: '/*/',
   endSuffix: '*/',
   space: true
};
```

---
_Source: https://npm.io/package/tagged-replace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
