docs/versions/8.4.0/rules/lib/builtins/TemplateDict.mdx
{% dynamic setvar source_file "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/TemplateDictApi.java" %} {% dynamic setvar version "8.4.0" %} {% dynamic setvar original_path "/rules/lib/builtins/TemplateDict" %} {% include "_buttons.html" %}
<!-- {% raw %} -->An Args-like structure for use in ctx.actions.expand_template(), which allows for deferring evaluation of values till the execution phase.
<h2>Members</h2> <ul> <li> <a href="#add">add</a> </li> <li> <a href="#add_joined">add_joined</a> </li> </ul> <h2 id="add">add</h2>
<p><pre class="rule-signature"><a class="anchor" href="../builtins/TemplateDict.html">TemplateDict</a> TemplateDict.add(key, value)</pre></p>
Add a String value
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="add.key">
<code>key</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
A String key
</td>
</tr>
<tr>
<td id="add.value">
<code>value</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
A String value
</td>
</tr>
</tbody>
</table>
<h2 id="add_joined">add_joined</h2>
<p><pre class="rule-signature"><a class="anchor" href="../builtins/TemplateDict.html">TemplateDict</a> TemplateDict.add_joined(key, values, *, join_with, map_each, uniquify=False, format_joined=None, allow_closure=False)</pre></p>
Add depset of values
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="add_joined.key">
<code>key</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
A String key
</td>
</tr>
<tr>
<td id="add_joined.values">
<code>values</code>
</td>
<td>
<a class="anchor" href="../builtins/depset.html">depset</a>;
required
The depset whose items will be joined.
</td>
</tr>
<tr>
<td id="add_joined.join_with">
<code>join_with</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>;
required
A delimiter string used to join together the strings obtained from applying <code>map_each</code>, in the same manner as <a href='../core/string.html#join'><code>string.join()</code></a>.
</td>
</tr>
<tr>
<td id="add_joined.map_each">
<code>map_each</code>
</td>
<td>
callable;
required
A Starlark function accepting a single argument and returning either a string, <code>None</code>, or a list of strings. This function is applied to each item of the depset specified in the <code>values</code> parameter
</td>
</tr>
<tr>
<td id="add_joined.uniquify">
<code>uniquify</code>
</td>
<td>
<a class="anchor" href="../core/bool.html">bool</a>;
default is <code>False</code>
If true, duplicate strings derived from <code>values</code> will be omitted. Only the first occurrence of each string will remain. Usually this feature is not needed because depsets already omit duplicates, but it can be useful if <code>map_each</code> emits the same string for multiple items.
</td>
</tr>
<tr>
<td id="add_joined.format_joined">
<code>format_joined</code>
</td>
<td>
<a class="anchor" href="../core/string.html">string</a>; or <code>None</code>;
default is <code>None</code>
An optional format string pattern applied to the joined string. The format string must have exactly one '%s' placeholder.
</td>
</tr>
<tr>
<td id="add_joined.allow_closure">
<code>allow_closure</code>
</td>
<td>
<a class="anchor" href="../core/bool.html">bool</a>;
default is <code>False</code>
If true, allows the use of closures in function parameters like <code>map_each</code>. Usually this isn't necessary and it risks retaining large analysis-phase data structures into the execution phase.
</td>
</tr>
</tbody>
</table>