Back to Bazel

TemplateDict

docs/versions/6.5.0/rules/lib/TemplateDict.mdx

9.1.04.7 KB
Original Source
<html devsite> <head> <meta name="project_path" value="/_project.yaml"> <meta name="book_path" value="/versions/6.5.0/_book.yaml"> </head> <body> <h1 class="page-title" id="modules.TemplateDict">TemplateDict</h1> <!-- {% 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="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>
                                 required

                      A String key
        </td>
      </tr>
              <tr>
        <td id="add.value">
          <code>value</code>
        </td>
        <td>
                                 required

                      A String value
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="add_joined">add_joined</h2>
    <p><pre class="rule-signature"><a class="anchor" href="TemplateDict.html">TemplateDict</a> TemplateDict.add_joined(key, values, *, join_with, map_each, uniquify=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>
                                 required

                      A String key
        </td>
      </tr>
              <tr>
        <td id="add_joined.values">
          <code>values</code>
        </td>
        <td>
                      <code><a class="anchor" href="depset.html">depset</a></code>;
                                 required

                      The depset whose items will be joined.
        </td>
      </tr>
              <tr>
        <td id="add_joined.join_with">
          <code>join_with</code>
        </td>
        <td>
                                 required

                      A delimiter string used to join together the strings obtained from applying <code>map_each</code>, in the same manner as <a href='string.html#join'><code>string.join()</code></a>.
        </td>
      </tr>
              <tr>
        <td id="add_joined.map_each">
          <code>map_each</code>
        </td>
        <td>
                      <code>callable</code>;
                                 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>
                                 default = False

                      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>
            </tbody>
  </table>
</body> </html> <!-- {% endraw %} -->