<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>局部模板函数 on Hugo 中文文档</title>
    <link>https://hugozh.cn/functions/partials/</link>
    <description>Recent content in 局部模板函数 on Hugo 中文文档</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Fri, 02 Oct 2026 01:21:54 +0800</lastBuildDate>
    <atom:link href="https://hugozh.cn/functions/partials/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>partials.Include</title>
      <link>https://hugozh.cn/functions/partials/include/</link>
      <pubDate>Fri, 02 Oct 2026 00:00:00 +0800</pubDate>
      <guid>https://hugozh.cn/functions/partials/include/</guid>
      <description>&lt;p&gt;没有 &lt;a href=&#34;https://hugozh.cn/functions/go-template/return/&#34;&gt;&lt;code&gt;return&lt;/code&gt;&lt;/a&gt; 语句时，&lt;code&gt;partial&lt;/code&gt; 函数返回 &lt;code&gt;template.HTML&lt;/code&gt; 类型的字符串。有 &lt;code&gt;return&lt;/code&gt; 语句时，&lt;code&gt;partial&lt;/code&gt; 函数可以返回任意数据类型。&lt;/p&gt;&#xA;&lt;p&gt;下例中有三个&lt;em&gt;局部模板&lt;/em&gt;：&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-tree&#34; data-lang=&#34;tree&#34;&gt;layouts/&#xA;└── _partials/&#xA;    ├── average.html&#xA;    ├── breadcrumbs.html&#xA;    └── footer.html&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;“average” &lt;em&gt;局部模板&lt;/em&gt;返回一个或多个数字的平均值。我们通过上下文传入这些数字：&lt;/p&gt;</description>
    </item>
    <item>
      <title>partials.IncludeCached</title>
      <link>https://hugozh.cn/functions/partials/includecached/</link>
      <pubDate>Fri, 02 Oct 2026 00:00:00 +0800</pubDate>
      <guid>https://hugozh.cn/functions/partials/includecached/</guid>
      <description>&lt;p&gt;没有 &lt;a href=&#34;https://hugozh.cn/functions/go-template/return/&#34;&gt;&lt;code&gt;return&lt;/code&gt;&lt;/a&gt; 语句时，&lt;code&gt;partialCached&lt;/code&gt; 函数返回 &lt;code&gt;template.HTML&lt;/code&gt; 类型的字符串。有 &lt;code&gt;return&lt;/code&gt; 语句时，&lt;code&gt;partialCached&lt;/code&gt; 函数可以返回任意数据类型。&lt;/p&gt;&#xA;&lt;p&gt;对于不需要每次调用都重新渲染的复杂模板，&lt;code&gt;partialCached&lt;/code&gt; 函数可以带来显著的性能提升。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
