Wrap Attributes
Config Key: wrap_attributes
Description: Wrap attributes to new lines
Available since version: 0.7.0 (Current: )
Type: string
Default: "auto"
Allowed values: "auto"
or "force"
or "force-aligned"
Support
Languages: HTML, Handlebars, Liquid, Mustache, XML
Beautifiers: JS-Beautify
Comparison Table
Language | JS-Beautify |
---|---|
HTML | ✅ |
Handlebars | ✅ |
Liquid | ✅ |
Mustache | ✅ |
XML | ✅ |
Examples
Carriage Return = ␍; Line Feed = ␊; Tab = ⇥; Whitespace = ·.
🚧 Original Code
<b·data-foo=""·data-bar=""></b>␊
<div·data-foo=""·data-bar=""></div>␊
<span·data-foo=""·data-bar=""></div>␊
␊
<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
␊
<input·type="hidden"·name="theName"·value="">␊
🔧 "auto"
Using JS-Beautify beautifier:
<b·data-foo=""·data-bar=""></b>␊
<div·data-foo=""·data-bar=""></div>␊
<span·data-foo=""·data-bar=""></div>␊
␊
··<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
␊
··<input·type="hidden"·name="theName"·value="">
How to configure
A .unibeautify.json
file would look like the following:
{
"HTML": {
"indent_size": 2,
"indent_char": " ",
"wrap_attributes": "auto",
"beautifiers": [
"JS-Beautify"
]
}
}
Difference from original
Index: auto
===================================================================
--- auto Original
+++ auto Beautified
@@ -1,7 +1,7 @@
<b·data-foo=""·data-bar=""></b>␊
<div·data-foo=""·data-bar=""></div>␊
<span·data-foo=""·data-bar=""></div>␊
␊
-<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
+··<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
␊
-<input·type="hidden"·name="theName"·value="">␊
+··<input·type="hidden"·name="theName"·value="">
\ No newline at end of file
🔧 "force"
Using JS-Beautify beautifier:
<b·data-foo=""␊
··data-bar=""></b>␊
<div·data-foo=""␊
··data-bar=""></div>␊
<span·data-foo=""␊
··data-bar=""></div>␊
␊
··<input·class="input·is-small"␊
····type="text"␊
····v-model="domainFilter"␊
····placeholder="search">␊
␊
··<input·type="hidden"␊
····name="theName"␊
····value="">
How to configure
A .unibeautify.json
file would look like the following:
{
"HTML": {
"indent_size": 2,
"indent_char": " ",
"wrap_attributes": "force",
"beautifiers": [
"JS-Beautify"
]
}
}
Difference from original
Index: force
===================================================================
--- force Original
+++ force Beautified
@@ -1,7 +1,15 @@
-<b·data-foo=""·data-bar=""></b>␊
-<div·data-foo=""·data-bar=""></div>␊
-<span·data-foo=""·data-bar=""></div>␊
+<b·data-foo=""␊
+··data-bar=""></b>␊
+<div·data-foo=""␊
+··data-bar=""></div>␊
+<span·data-foo=""␊
+··data-bar=""></div>␊
␊
-<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
+··<input·class="input·is-small"␊
+····type="text"␊
+····v-model="domainFilter"␊
+····placeholder="search">␊
␊
-<input·type="hidden"·name="theName"·value="">␊
+··<input·type="hidden"␊
+····name="theName"␊
+····value="">
\ No newline at end of file
🔧 "force-aligned"
Using JS-Beautify beautifier:
<b·data-foo=""␊
···data-bar=""></b>␊
<div·data-foo=""␊
·····data-bar=""></div>␊
<span·data-foo=""␊
······data-bar=""></div>␊
␊
··<input·class="input·is-small"␊
·········type="text"␊
·········v-model="domainFilter"␊
·········placeholder="search">␊
␊
··<input·type="hidden"␊
·········name="theName"␊
·········value="">
How to configure
A .unibeautify.json
file would look like the following:
{
"HTML": {
"indent_size": 2,
"indent_char": " ",
"wrap_attributes": "force-aligned",
"beautifiers": [
"JS-Beautify"
]
}
}
Difference from original
Index: force-aligned
===================================================================
--- force-aligned Original
+++ force-aligned Beautified
@@ -1,7 +1,15 @@
-<b·data-foo=""·data-bar=""></b>␊
-<div·data-foo=""·data-bar=""></div>␊
-<span·data-foo=""·data-bar=""></div>␊
+<b·data-foo=""␊
+···data-bar=""></b>␊
+<div·data-foo=""␊
+·····data-bar=""></div>␊
+<span·data-foo=""␊
+······data-bar=""></div>␊
␊
-<input·class="input·is-small"·type="text"·v-model="domainFilter"·placeholder="search">␊
+··<input·class="input·is-small"␊
+·········type="text"␊
+·········v-model="domainFilter"␊
+·········placeholder="search">␊
␊
-<input·type="hidden"·name="theName"·value="">␊
+··<input·type="hidden"␊
+·········name="theName"␊
+·········value="">
\ No newline at end of file