muninn
GitHubExtensionWope
  • Introduction
  • Config
    • Basic
    • Selector
    • Array
    • Attribute
    • Type
    • Regex
    • Transform
    • Array Transform
    • Exist
    • Schema
    • Trim
    • Initial
    • Fill
    • HTML
    • Methods
Powered by GitBook
On this page

Was this helpful?

  1. Config

Attribute

Sometimes we would like to use an attribution of an item. It is enough to use the attr feature to ensure that.

HTML
<div class="parent">
  <a href="/about">About</div>
</div>
Config
{
    "link": {
        "selector": "a",
        "attr": "href"
    },
}

// or use this shortcut

{
    "link": "a @ href"
}
Output
{
    "link": "/about" 
}

Multiple Attributes

HTML
<div class="parent">
  <a href="https://google.com" rel="noreferrer">Google</div>
</div>
Config
{
    "link": {
        "selector": "a",
        "attr": ["href", "rel"]
    },
}

// or use this shortcut

{
    "link": "a @ href, rel"
}
Output
{
    "link": {
        "href": "https://google.com",
        "rel": "noreferrer"
    }
}

All Attributes

{
    "link": {
        "selector": "a",
        "attr": "$all"
    },
}

// or use this shortcut

{
    "link": "a @ $all"
}
Output
{
    "link": {
        "href": "https://google.com",
        "rel": "noreferrer"
    }
}j
PreviousArrayNextType

Last updated 2 years ago

Was this helpful?