# ★ replaceText()

## `Wrap.prototype.replaceText()`

Returns the [primitive value](https://docs.angular-package.dev/wrapper/wrap/methods/instance/valueof) with replaced [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text).

{% code title="wrap.class.ts" %}

```typescript
public replaceText<ReplaceText extends string = ''>(
  text: ReplaceText
): `${Opening}${ReplaceText}${Closing}` {
  return `${this.#opening}${text}${this.#closing}`;
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">**`ReplaceText`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>**`=`**<mark style="color:green;">**`''`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`text`](#text-replacetext) indicates the `ReplaceText` type on the template of the [return type](#return-type).

### Parameters

#### `text: ReplaceText`

The text of a generic type variable [`ReplaceText`](#replacetext-extends-string) to replace the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) in the [primitive value](https://docs.angular-package.dev/wrapper/wrap/methods/instance/valueof).

### Return type

#### `${Opening}${ReplaceText}${Closing}`

The **return type** is the [template literal](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html) of generic type variables in order [`Opening`](https://docs.angular-package.dev/wrapper/generic-type-variables#wrap-opening), [`ReplaceText`](#replacetextextendsstring) and [`Closing`](https://docs.angular-package.dev/wrapper/generic-type-variables#wrap-closing).&#x20;

### Returns

The **return value** is the [primitive value](https://docs.angular-package.dev/wrapper/wrap/methods/instance/valueof) with replaced [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) of a generic type variables in order [`Opening`](https://docs.angular-package.dev/wrapper/generic-type-variables#wrap-opening), [`ReplaceText`](#replacetextextendsstring) and [`Closing`](https://docs.angular-package.dev/wrapper/generic-type-variables#wrap-closing) on the template.

## Example usage

```typescript
// Example usage.
import { Wrap } from '@angular-package/wrapper';

// Returns [span] of type "[span]".
new Wrap(`[`, `]`, 'quote').replaceText('span');

// Returns [bold] of "[bold]".
new Wrap(`[`, `]`, '').replaceText('bold');

// Returns [u] of "[u]".
new Wrap(`[`, `]`).replaceText('u');

// Returns size] of "size]".
new Wrap(``, `]`).replaceText('size');

// Returns [size of "[size".
new Wrap(`[`, ``).replaceText('size');
```
