Tag
PackagesTwitterGitHub
  • Introduction
  • General concepts
  • Getting started
    • Skeleton
    • Installation
    • Public API
  • Attribute
    • Code
    • Attribute {}
    • Generic type variables
    • ★ Attribute() constructor
    • Instance
      • Accessors
        • attribute
        • name
        • value
        • [Symbol.toStringTag]
      • Properties
        • #name
        • #value
      • Methods
        • toArray()
        • toObject()
        • toString()
        • valueOf()
    • Static
      • Methods
        • isAttribute()
    • Usage
  • Attributes
    • Attributes {}
    • Generic type variables
    • Instance
      • Accessors
      • Properties
    • Attributes() constructor
    • Instance methods
    • Usage
  • Tag
    • Tag {}
    • Usage
  • Tag Extension
    • TagExtension {}
    • Usage
  • tags
    • Tags {}
    • Usage
  • BBCode
    • BBCode {}
    • Usage
  • Html
    • HTML {}
    • Usage
  • Variable
    • Variable {}
    • Usage
  • Variables
    • Variables {}
    • Usage
  • Types
    • ClosingTag
    • OpeningTag
    • TaggedText
  • License
    • MIT
  • Contact
    • ⋯ Chat
    • @ Email
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
Powered by GitBook
On this page
  • Attribute()
  • Parameters
  • Returns
  • Example usage

Was this helpful?

Edit on GitHub
  1. Attribute

★ Attribute() constructor

PreviousGeneric type variablesNextInstance

Last updated 3 years ago

Was this helpful?

Attribute()

Creates a new instance with the name and value.

attribute.class.ts
constructor(name: Name, value: Value) {
  super(Attribute.template`${name}${value}`);
  this.#name = String(name) as Name;
  this.#value = String(value) as Value;
}

Parameters

Name: type
Description

name: Name

The attribute name of a generic type variable Name.

value: Value

The attribute value of a generic type variable Value.

Returns

The return value is a new instance with the primitive value of the provided name and value on the template ${Name}="${Value}".

Example usage

// Example usage.
import { Attribute } from '@angular-package/tag';

// Returns Attribute {'color="red"'} of type Attribute<"color", "red">.
new Attribute('color', 'red');
Attribute
Attribute