You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li>It sends each event immediately in legacy mode, mimicking a step-by-step log.</li>
3025
3025
</ul>
3026
3026
<h3id="using_simple_templates_in_the_preview_tool">Using Simple Templates in the Preview Tool<aclass="headerlink" href="#using_simple_templates_in_the_preview_tool" title="Permanent link">¶</a></h3>
3027
-
<p>The <ahref="../template-preview/">Template Preview Tool</a> uses a <code>notifications.Data</code> struct with <code>.Entries</code> as the log list.</p>
3027
+
<p>The <ahref="../template-preview/">Template Preview Tool</a> uses the same template root as Watchtower:</p>
3028
+
<ul>
3029
+
<li>Report toggle off (legacy mode): the root is the log entry slice. Range over <code>.</code>, the same as the default simple template above.</li>
3030
+
<li>Report toggle on (report mode): the root is a <code>notifications.Data</code> value. Range over <code>.Entries</code> (and use <code>.Report</code> for session results).</li>
3031
+
</ul>
3028
3032
<divclass="admonition note">
3029
3033
<pclass="admonition-title">Note</p>
3030
-
<p>To use the simple template in the preview tool, modify the range to<code>{{- range $i, $e := .Entries -}}</code>to match the data structure.</p>
3034
+
<p>The example below is for report mode. With the report toggle off, use<code>range .</code>instead of <code>range .Entries</code>.</p>
3031
3035
</div>
3032
-
<divclass="highlight"><spanclass="filename">Example Simple Template for the Template Preview Tool</span><pre><span></span><code><aid="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><spanclass="p">{{</span><spanclass="o">-</span><spanclass="w"></span><spanclass="k">range</span><spanclass="w"></span><spanclass="err">$</span><spanclass="nx">i</span><spanclass="p">,</span><spanclass="w"></span><spanclass="err">$</span><spanclass="nx">e</span><spanclass="w"></span><spanclass="o">:=</span><spanclass="w"></span><spanclass="p">.</span><spanclass="nx">Entries</span><spanclass="w"></span><spanclass="o">-</span><spanclass="p">}}</span>
3036
+
<divclass="highlight"><spanclass="filename">Preview example (report mode)</span><pre><span></span><code><aid="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><spanclass="p">{{</span><spanclass="o">-</span><spanclass="w"></span><spanclass="k">range</span><spanclass="w"></span><spanclass="err">$</span><spanclass="nx">i</span><spanclass="p">,</span><spanclass="w"></span><spanclass="err">$</span><spanclass="nx">e</span><spanclass="w"></span><spanclass="o">:=</span><spanclass="w"></span><spanclass="p">.</span><spanclass="nx">Entries</span><spanclass="w"></span><spanclass="o">-</span><spanclass="p">}}</span>
<aid="__codelineno-6-4" name="__codelineno-6-4" href="#__codelineno-6-4"></a><spanclass="p">{{</span><spanclass="o">-</span><spanclass="w"></span><spanclass="k">if</span><spanclass="w"></span><spanclass="nx">eq</span><spanclass="w"></span><spanclass="err">$</span><spanclass="nx">msg</span><spanclass="w"></span><spanclass="s">"Found new image"</span><spanclass="w"></span><spanclass="o">-</span><spanclass="p">}}</span>
<p>Use the <ahref="../template-preview/">Template Preview Tool</a> to test your templates interactively.</p>
3182
3186
<divclass="admonition note">
3183
3187
<pclass="admonition-title">Note</p>
3184
-
<p>When testing simple templates in the preview tool, ensure the range iterates over <code>.Entries</code>(e.g., <code>{{- range $i, $e := .Entries -}}</code>) to match the <code>notifications.Data</code> struct.</p>
3188
+
<p>When the preview report toggle is off, simple templates can range over <code>.</code>just as they do in Watchtower. When the report toggle is on, range over <code>.Entries</code>.</p>
0 commit comments