angular-package
TwitterGitHub
Text
Text
  • Introduction
  • Benefits
  • Getting started
    • General concepts
    • Skeleton
    • Installation
    • Public API
  • Wrapper
    • Basic concepts
    • Wrap
      • Generic type variables
      • Instance accessors
      • Instance properties
      • Static methods
      • Wrap() constructor
      • Instance methods
      • Examples
    • Wrapper
      • Generic type variables
      • Static properties
      • Instance accessors
      • Static methods
      • Wrapper() constructor
      • Instance methods
      • Examples
    • Wrapped
      • Generic type variables
      • Instance accessors
      • Instance properties
      • Static methods
      • Wrapped() constructor
      • Instance methods
      • Types
      • Examples
  • Tag
    • Basic concepts
    • Tag
      • Generic type variables
      • Static accessors
      • Static properties
      • Instance accessors
      • Instance properties
      • Static methods
      • Tag() constructor
      • Instance methods
      • Types
      • Examples
    • BBCodeTag
      • Static methods
      • BBCodeTag() constructor
    • HtmlTag
      • Generic type variables
      • HtmlTag() constructor
    • Tags
    • Tagged
  • Main
    • AllowedChars
    • Attribute
      • Generic type variables
      • Instance accessors
      • Instance properties
      • Static methods
      • Attribute() constructor
      • Instance methods
    • Attributes
    • Template
    • Text
  • Legend
    • Property tags
  • Other
    • Contact
    • Sponsor
  • More versions
Powered by GitBook
On this page
  • Public
  • Tag.prototype.getClosingTag()
  • Tag.prototype.getName()
  • Tag.prototype.getOpeningTag()
  • Tag.prototype.getWrap()
  • Tag.prototype.replaceTag()
  • Tag.prototype.tagText()
  • Tag.prototype.valueOf()

Was this helpful?

  1. Tag
  2. Tag

Instance methods

Tag.prototype.

PreviousTag() constructorNextTypes

Last updated 3 years ago

Was this helpful?

Public

Tag.prototype.getClosingTag()

Gets the of a specified object.

public getClosingTag(): ClosingTag<Name, Chars> {
  return this.closingTag;
}

Returns

The return value is the closing tag of a generic type .

Tag.prototype.getName()

Gets the tag name without the and char.

public getName(): Name {
  return this.#name;
}

Returns

Tag.prototype.getOpeningTag()

public getOpeningTag(): OpeningTag<Name, Chars> {
  return this.tag as OpeningTag<Name, Chars>;
}

Returns

Tag.prototype.getWrap()

public getWrap(): Wrap<Chars> {
  return this.#wrap;
}

Returns

Tag.prototype.replaceTag()

Need to know: The return type of a generic type variable Text returns the text with not replaced tags.

public replaceTag<Text extends string>(
  text: Text,
  replaceValue?: string
): Text {
  return guardString(text)
    ? isString(replaceValue)
      ? (text.split(this.tag).join(replaceValue) as Text)
      : text
    : ('' as Text);
}

Generic Type variables

Name / Description

Text extends string

Parameters

Name: type
Description

text: Text

The text in which to replace a tag of a specified object with a given replaceValue.

replaceValue?: string

The value to replace a tag of a specified object in the given text.

Returns

The return value is the given text of a generic type variable Text with a replaced tag if both the text and replaceValue are strings. If replaceValue is not a string returns not replaced text, and if both the text and replaceValue are not strings returns an empty string.

Tag.prototype.tagText()

public tagText<Text extends string>(text: Text): Tagged<Text, Name, Chars> {
  return new Tagged(
    `${this.openingTag}${text}${this.closingTag}` as Text,
    this
  );
}

Generic type variables

Name / Description

Text extends string

Parameters

Name: type
Description

text: Text

The text of a string type, to be tagged with the opening and closing tag.

Returns

Example usage

// Example usage.
import { tagText } from '@angular-package/text';

// Define the tag.
const quote = new Tag(`quote`);

// Tag the text with a `quote` tag.
// Returns Tagged {`[quote]"It's a possible."[/quote]`}
quote.tagText(`"It's a possible."`);

Tag.prototype.valueOf()

public valueOf(): Name {
  return super.valueOf() as Name;
}

Returns

The return value is the tag name of a generic type variable .

Gets the of the specified object.

The return value is the opening tag of a generic type .

Gets the of a tag name.

The return value is an instance of .

The method replaces the tag of a specified object with the provided replaceValue in the given text if both values are strings.

​A generic type variable constrained by the by default of the value captured from the provided text parameter indicates the type of Text via the return type.

The method the provided text with the and tag.

​A generic type variable constrained by the by default of the value captured from the provided text parameter indicates the type of via the return type.

The return value is a new instance with a tagged text.

Returns tag name, a primitive value of the specified object.

The return value is a tag name of a generic type variable .

Wrap
Tag
Tagged
Tag
string
string
Tagged
Tag
Tag
opening
closing
opening tag
OpeningTag
ClosingTag
wrap
Name
Name
tags
closing tag
opening
closing