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

Type

PreviousAttributeNextRegex

Last updated 3 years ago

Was this helpful?

Muninn can turn data into the desired types during the parsing stage.

Available Types

  • number

  • float

  • boolean

  • array

Array

Number

HTML
<div class="parent">
  <div class="year">1984</div>
</div>
Config
{
    "year": {
        "selector": ".year",
        "type": "number"
    },
}

// or use this shortcut

{
    "year": ".year | number"
}
Output
{
    "year": 1984 
}

Float

HTML
<div class="parent">
  <div class="price">2.99</div>
</div>
Config
{
    "price": {
        "selector": ".price",
        "type": "float"
    },
}

// or use this shortcut

{
    "price": ".price | float"
}
Output
{
    "price": 2.99
}

Boolean

For various reasons, we may want to convert a value to the Boolean type. Let's start with an example we check that the content of the element is empty.

HTML
<div class="parent">
  <div class="content-1">Lorem Ipsum</div>
  <div class="content-2"></div>
</div>
Config
{
    "isExistContent1": {
        "selector": ".content-1",
        "type": "boolean"
    },
    "isExistContent2": {
        "selector": ".content-2",
        "type": "boolean"
    },
}

// or use this shortcut

{
    "isExistContent1": ".content-1 | boolean",
    "isExistContent2": ".content-2 | boolean"
}
Output
{
    "isExistContent1": true,
    "isExistContent2": false,
}
Array