From e7df21426b2387ecb57f9af5910a112c6e9c5afa Mon Sep 17 00:00:00 2001
From: Gesina Schwalbe <gesina.schwalbe@pheerai.de>
Date: Mon, 28 Dec 2020 18:58:01 +0100
Subject: [PATCH] removed code duplication in item templates

Item templates now all use a common body.
---
 src/module/ds4.ts                      |  1 +
 src/templates/item/armor-sheet.hbs     | 22 ++--------------------
 src/templates/item/equipment-sheet.hbs | 22 ++--------------------
 src/templates/item/partials/body.hbs   | 22 ++++++++++++++++++++++
 src/templates/item/shield-sheet.hbs    | 22 ++--------------------
 src/templates/item/trinket-sheet.hbs   | 22 ++--------------------
 src/templates/item/weapon-sheet.hbs    | 22 ++--------------------
 7 files changed, 33 insertions(+), 100 deletions(-)
 create mode 100644 src/templates/item/partials/body.hbs

diff --git a/src/module/ds4.ts b/src/module/ds4.ts
index c5d0f99b..8b67b9f7 100644
--- a/src/module/ds4.ts
+++ b/src/module/ds4.ts
@@ -35,6 +35,7 @@ async function registerHandlebarsPartials() {
         "systems/ds4/templates/item/partials/description.hbs",
         "systems/ds4/templates/item/partials/details.hbs",
         "systems/ds4/templates/item/partials/effects.hbs",
+        "systems/ds4/templates/item/partials/body.hbs",
     ];
     return loadTemplates(templatePaths);
 }
diff --git a/src/templates/item/armor-sheet.hbs b/src/templates/item/armor-sheet.hbs
index b720df0e..a0a671dc 100644
--- a/src/templates/item/armor-sheet.hbs
+++ b/src/templates/item/armor-sheet.hbs
@@ -34,24 +34,6 @@
         </div>
     </header>
 
-    {{!-- Sheet Tab Navigation --}}
-    <nav class="sheet-tabs tabs" data-group="primary">
-        <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
-        <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
-        <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
-    </nav>
-
-    {{!-- Sheet Body --}}
-    <section class="sheet-body">
-
-        {{!-- Description Tab --}}
-        {{> systems/ds4/templates/item/partials/description.hbs}}
-
-        {{!-- Details Tab --}}
-        {{> systems/ds4/templates/item/partials/details.hbs}}
-
-        {{!-- Effects Tab --}}
-        {{> systems/ds4/templates/item/partials/effects.hbs}}
-        
-    </section>
+    {{!-- Common Item body --}}
+    {{> systems/ds4/templates/item/partials/body.hbs}}
 </form>
\ No newline at end of file
diff --git a/src/templates/item/equipment-sheet.hbs b/src/templates/item/equipment-sheet.hbs
index 25434bf5..5c2c3d4e 100644
--- a/src/templates/item/equipment-sheet.hbs
+++ b/src/templates/item/equipment-sheet.hbs
@@ -7,24 +7,6 @@
         </div>
     </header>
 
-    {{!-- Sheet Tab Navigation --}}
-    <nav class="sheet-tabs tabs" data-group="primary">
-        <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
-        <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
-        <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
-    </nav>
-
-    {{!-- Sheet Body --}}
-    <section class="sheet-body">
-
-        {{!-- Description Tab --}}
-        {{> systems/ds4/templates/item/partials/description.hbs}}
-
-        {{!-- Details Tab --}}
-        {{> systems/ds4/templates/item/partials/details.hbs}}
-
-        {{!-- Effects Tab --}}
-        {{> systems/ds4/templates/item/partials/effects.hbs}}
-        
-    </section>
+    {{!-- Common Item body --}}
+    {{> systems/ds4/templates/item/partials/body.hbs}}
 </form>
\ No newline at end of file
diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs
new file mode 100644
index 00000000..9b5cde20
--- /dev/null
+++ b/src/templates/item/partials/body.hbs
@@ -0,0 +1,22 @@
+{{!-- Template for the common body (navigation & body sections) of all items. --}}
+
+{{!-- Sheet Tab Navigation --}}
+<nav class="sheet-tabs tabs" data-group="primary">
+    <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
+    <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
+    <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
+</nav>
+
+{{!-- Sheet Body --}}
+<section class="sheet-body">
+
+    {{!-- Description Tab --}}
+    {{> systems/ds4/templates/item/partials/description.hbs}}
+
+    {{!-- Details Tab --}}
+    {{> systems/ds4/templates/item/partials/details.hbs}}
+
+    {{!-- Effects Tab --}}
+    {{> systems/ds4/templates/item/partials/effects.hbs}}
+    
+</section>
\ No newline at end of file
diff --git a/src/templates/item/shield-sheet.hbs b/src/templates/item/shield-sheet.hbs
index b06ecb45..1e893d2a 100644
--- a/src/templates/item/shield-sheet.hbs
+++ b/src/templates/item/shield-sheet.hbs
@@ -14,24 +14,6 @@
         </div>
     </header>
 
-    {{!-- Sheet Tab Navigation --}}
-    <nav class="sheet-tabs tabs" data-group="primary">
-        <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
-        <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
-        <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
-    </nav>
-
-    {{!-- Sheet Body --}}
-    <section class="sheet-body">
-
-        {{!-- Description Tab --}}
-        {{> systems/ds4/templates/item/partials/description.hbs}}
-
-        {{!-- Details Tab --}}
-        {{> systems/ds4/templates/item/partials/details.hbs}}
-
-        {{!-- Effects Tab --}}
-        {{> systems/ds4/templates/item/partials/effects.hbs}}
-        
-    </section>
+    {{!-- Common Item body --}}
+    {{> systems/ds4/templates/item/partials/body.hbs}}
 </form>
\ No newline at end of file
diff --git a/src/templates/item/trinket-sheet.hbs b/src/templates/item/trinket-sheet.hbs
index 25434bf5..5c2c3d4e 100644
--- a/src/templates/item/trinket-sheet.hbs
+++ b/src/templates/item/trinket-sheet.hbs
@@ -7,24 +7,6 @@
         </div>
     </header>
 
-    {{!-- Sheet Tab Navigation --}}
-    <nav class="sheet-tabs tabs" data-group="primary">
-        <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
-        <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
-        <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
-    </nav>
-
-    {{!-- Sheet Body --}}
-    <section class="sheet-body">
-
-        {{!-- Description Tab --}}
-        {{> systems/ds4/templates/item/partials/description.hbs}}
-
-        {{!-- Details Tab --}}
-        {{> systems/ds4/templates/item/partials/details.hbs}}
-
-        {{!-- Effects Tab --}}
-        {{> systems/ds4/templates/item/partials/effects.hbs}}
-        
-    </section>
+    {{!-- Common Item body --}}
+    {{> systems/ds4/templates/item/partials/body.hbs}}
 </form>
\ No newline at end of file
diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs
index 09b3facf..37c0aa2c 100644
--- a/src/templates/item/weapon-sheet.hbs
+++ b/src/templates/item/weapon-sheet.hbs
@@ -29,24 +29,6 @@
         </div>
     </header>
 
-    {{!-- Sheet Tab Navigation --}}
-    <nav class="sheet-tabs tabs" data-group="primary">
-        <a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
-        <a class="item" data-tab="effects">{{localize "DS4.Effects"}}</a>
-        <a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
-    </nav>
-
-    {{!-- Sheet Body --}}
-    <section class="sheet-body">
-
-        {{!-- Description Tab --}}
-        {{> systems/ds4/templates/item/partials/description.hbs}}
-
-        {{!-- Details Tab --}}
-        {{> systems/ds4/templates/item/partials/details.hbs}}
-
-        {{!-- Effects Tab --}}
-        {{> systems/ds4/templates/item/partials/effects.hbs}}
-        
-    </section>
+    {{!-- Common Item body --}}
+    {{> systems/ds4/templates/item/partials/body.hbs}}
 </form>
\ No newline at end of file