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

Was this helpful?

  1. Wrapper
  2. Wrap

Examples

Let's create a wrap for the BBCode tag.

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

// Let's create a BBCode wrap.
const BBCodeWrap = new Wrap('[', ']');

// Make a [quote] BBCode tag. Returns Wrapped {'[quote]'}
const quoteTag = BBCodeWrap.wrapText('quote');
console.log(quoteTag);
quoteTag.opening; // Returns [
quoteTag.closing; // Returns ]
quoteTag.text; // Returns [quote]
quoteTag.value; // Returns [quote]
quoteTag.unwrap(); // Returns quote
quoteTag.valueOf(); // Returns [quote]

// Make a [img] BBCode tag. Returns Wrapped {'[img]'}
const imgTag = BBCodeWrap.wrapText('img');

Let's create a wrap for the HTML tag.

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

// Let's create a HTML wrap.
const HTMLWrap = new Wrap('<', '>');

// Returns Wrapped {'<span>'}
const spanTag = HTMLWrap.wrapText('span');
spanTag.opening; // Returns <
spanTag.closing; // Returns >
spanTag.text; // Returns <span>
spanTag.value; // Returns <span>
spanTag.unwrap(); // Returns span
spanTag.valueOf(); // Returns <span>
PreviousInstance methodsNextWrapper

Last updated 3 years ago

Was this helpful?