use #with for simple template fragments guarded by truthy checks
authorDan Allen <dan@opendevise.com>
Wed, 8 Apr 2020 07:22:13 +0000 (01:22 -0600)
committerDan Allen <dan@opendevise.com>
Wed, 8 Apr 2020 07:22:13 +0000 (01:22 -0600)
src/partials/article.hbs
src/partials/head-info.hbs
src/partials/head-scripts.hbs
src/partials/head-title.hbs
src/partials/toolbar.hbs

index 11a5117..edd5a08 100644 (file)
@@ -9,9 +9,9 @@
 If you typed the URL of this page manually, please double check that you entered the address correctly.</p>
 </div>
 {{else}}
-{{#if page.title}}
-<h1 class="page">{{{page.title}}}</h1>
-{{/if}}
+{{#with page.title}}
+<h1 class="page">{{{this}}}</h1>
+{{/with}}
 {{{page.contents}}}
 {{/if}}
 </article>
index 71012a1..bf1f19b 100644 (file)
@@ -1,13 +1,13 @@
-    {{#if page.canonicalUrl}}
-    <link rel="canonical" href="{{page.canonicalUrl}}">
-    {{/if}}
+    {{#with page.canonicalUrl}}
+    <link rel="canonical" href="{{this}}">
+    {{/with}}
     {{#if page.component}}
-    {{#if page.description}}
-    <meta name="description" content="{{page.description}}">
-    {{/if}}
-    {{#if page.keywords}}
-    <meta name="keywords" content="{{page.keywords}}">
-    {{/if}}
+    {{#with page.description}}
+    <meta name="description" content="{{this}}">
+    {{/with}}
+    {{#with page.keywords}}
+    <meta name="keywords" content="{{this}}">
+    {{/with}}
     {{/if}}
     {{#with (or antoraVersion site.antoraVersion)}}
     <meta name="generator" content="Antora {{this}}">
index 41ad69e..e7da2bb 100644 (file)
@@ -1,4 +1,4 @@
-    {{#if site.keys.googleAnalytics}}
-    <script async src="https://www.googletagmanager.com/gtag/js?id={{site.keys.googleAnalytics}}"></script>
-    <script>function gtag(){dataLayer.push(arguments)};window.dataLayer=window.dataLayer||[];gtag('js',new Date());gtag('config','{{site.keys.googleAnalytics}}')</script>
-    {{/if}}
+    {{#with site.keys.googleAnalytics}}
+    <script async src="https://www.googletagmanager.com/gtag/js?id={{this}}"></script>
+    <script>function gtag(){dataLayer.push(arguments)};window.dataLayer=window.dataLayer||[];gtag('js',new Date());gtag('config','{{this}}')</script>
+    {{/with}}
index c96c8f2..924fcac 100644 (file)
@@ -1 +1 @@
-    <title>{{{detag (or page.title defaultPageTitle)}}}{{#if site.title}} :: {{site.title}}{{/if}}</title>
+    <title>{{{detag (or page.title defaultPageTitle)}}}{{#with site.title}} :: {{this}}{{/with}}</title>
index 4e6f59b..dd4e3d7 100644 (file)
@@ -1,8 +1,8 @@
 <div class="toolbar" role="navigation">
 {{> nav-toggle}}
-  {{#if site.homeUrl}}
-  <a href="{{relativize site.homeUrl}}" class="home-link{{#if page.home}} is-current{{/if}}"></a>
-  {{/if}}
+  {{#with site.homeUrl}}
+  <a href="{{relativize this}}" class="home-link{{#if @root.page.home}} is-current{{/if}}"></a>
+  {{/with}}
 {{> breadcrumbs}}
 {{> page-versions}}
   {{#if (and page.fileUri (not env.CI))}}