angular-package
TwitterGitHub
Wrapper
Wrapper
  • Introduction
  • ❤ Benefits
    • Explanation
    • Designing
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Wrap {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • closing
      • opening
      • text
      • [Symbol.toStringTag]
    • Properties
      • #closing
      • #opening
      • #text
    • Methods
      • Static
        • hasClosing()
        • hasOpening()
        • isWrap()
      • Instance
        • getClosing()
        • getOpening()
        • getText()
        • hasClosing()
        • hasOpening()
        • hasText()
        • isWrapped()
        • ★ replaceClosing()
        • ★ replaceOpening()
        • ★ replaceText()
        • toString()
        • valueOf()
    • Example usage
  • Wrapper {}
    • Overview
    • Generic type variables
    • Constructor
    • Accessors
      • [Symbol.toStringTag]
    • Methods
      • Static
        • define()
        • isWrapper()
        • replaceClosing()
        • replaceOpening()
        • unwrap()
      • Instance
        • isClosingIn()
        • isOpeningIn()
        • replaceClosingIn()
        • replaceOpeningIn()
        • removeWrapIn()
        • textReplaceClosing()
        • textReplaceOpening()
        • ⚠ textHasClosing()
        • ⚠ textHasOpening()
        • textUnwrap()
        • textWrap()
        • toArray()
        • toWrap()
        • unwrap()
        • unwrapText()
        • ★ wrap()
        • ★ wrapOn()
        • ★ wrapText()
    • Example usage
  • Type
    • Wrapped
  • Change log
    • Keep a changelog
    • CHANGELOG.md
    • v1.0.0
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Contact
    • ⋯ Chat
    • @ Email
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
  • More versions
Powered by GitBook
On this page
  • BBCode tag
  • Html tag

Was this helpful?

  1. Wrap {}

Example usage

BBCode tag

Let's create a wrap for the BBCode tag.

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

// Let's create a BBCode wrap.
class BBCode<Name extends string> extends Wrap<`[`, Name, `]`> {
  constructor(name: Name) {
    super(`[`, `]`, name);
  }
}

// Make a [quote] BBCode tag. Returns BBCode {'[quote]'} of type BBCode<"quote">
const quoteTag = new BBCode('quote');

quoteTag.opening; // Returns [
quoteTag.closing; // Returns ]
quoteTag.text; // Returns quote
quoteTag.valueOf(); // Returns [quote]
quoteTag.getClosing();  // Returns [
quoteTag.getOpening(); // Returns ]
quoteTag.getText();  // Returns quote

// Make a [img] BBCode tag. Returns BBCode {'[img]'} of type BBCode<"img">
const imgTag = new BBCode('img');

Html tag

Let's create a wrap for the HTML tag.

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

// Let's create a Html wrap.
class Html<Name extends string> extends Wrap<`<`, Name, `>`> {
  constructor(name: Name) {
    super(`<`, `>`, name);
  }
}

// Make a <span> Html tag. Returns Html{'<span>'} of type Html<"span">
const spanTag = new Html('span');
spanTag.opening; // Returns <
spanTag.closing; // Returns >
spanTag.text; // Returns span
spanTag.valueOf(); // Returns <span>
spanTag.getClosing();  // Returns <
spanTag.getOpening(); // Returns >
spanTag.getText();  // Returns <span>

// Make a <img> Html tag. Returns Html{'<img>'} of type Html<"img">
const imgTag = new Html('img');
PreviousvalueOf()NextOverview

Last updated 3 years ago

Was this helpful?