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
  • Idea
  • Elements

Was this helpful?

Introduction

Text on the template with replaceable tags.

NextBenefits

Last updated 3 years ago

Was this helpful?

Idea

The package was created on the idea of having the ability to create a short text on a changeable template with ease-replaceable tags inside it.

Some of its elements are based on , exactly the string object, which is immutable. They were built as general objects with intuitive names, unique and most important features for their names, and in a simple ease-extendable form. One of the pros of this approach is the functionality follows the type because these objects can be used as the types, which results in fewer typescript types.

There are two ways using the method of an instance, the method do actions on the instance or the method use the instance to do some action. Because of the immutable nature of the primitive wrapper objects there are often method uses instance to do some action.

Elements

Let's deep dive into the elements of the text package. From the bottom of the build hierarchy, there's a Wrap string object that represents a two-character wrap with its main ability to wrap a specified text. This wrap result in a Wrapped string object of the wrapped text.

To create a Wrap object there is a need to use a new operator, and in addition to this, there's an object Wrapper, which helps create it with predefined allowed characters and also wrap the specified text with the use of predefined Wrap. So, it is simply a configurable "machine" to build a wrap in a restricted range of characters.

Of course, the Wrap object gives a possibility to create a new object with additional features by simply extending it. And by this way string object named Tag was created with its main ability to build a tag of a specified name and wrap(e.g. like an HTML tag), which is used to tag a specified text with an opening tag and an automatically created the closing tag.

The last two in the build hierarchy are respectively the Template and Text, where the first is a string object that contains tags and its equivalent Tag objects, and the second is an object consisting of string text and string object Template to replace the tags with real words.

What are the benefits of this approach? Read the next section.

primitive wrapper objects