xref: /aosp_15_r20/external/bazel-skylib/docs/expand_template_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifan<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2*bcb5dc79SHONG Yifan
3*bcb5dc79SHONG YifanA rule that performs template expansion.
4*bcb5dc79SHONG Yifan
5*bcb5dc79SHONG Yifan<a id="expand_template"></a>
6*bcb5dc79SHONG Yifan
7*bcb5dc79SHONG Yifan## expand_template
8*bcb5dc79SHONG Yifan
9*bcb5dc79SHONG Yifan<pre>
10*bcb5dc79SHONG Yifanexpand_template(<a href="#expand_template-name">name</a>, <a href="#expand_template-out">out</a>, <a href="#expand_template-substitutions">substitutions</a>, <a href="#expand_template-template">template</a>)
11*bcb5dc79SHONG Yifan</pre>
12*bcb5dc79SHONG Yifan
13*bcb5dc79SHONG YifanTemplate expansion
14*bcb5dc79SHONG Yifan
15*bcb5dc79SHONG YifanThis performs a simple search over the template file for the keys in
16*bcb5dc79SHONG Yifansubstitutions, and replaces them with the corresponding values.
17*bcb5dc79SHONG Yifan
18*bcb5dc79SHONG YifanThere is no special syntax for the keys. To avoid conflicts, you would need to
19*bcb5dc79SHONG Yifanexplicitly add delimiters to the key strings, for example "{KEY}" or "@KEY@".
20*bcb5dc79SHONG Yifan
21*bcb5dc79SHONG Yifan**ATTRIBUTES**
22*bcb5dc79SHONG Yifan
23*bcb5dc79SHONG Yifan
24*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
25*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
26*bcb5dc79SHONG Yifan| <a id="expand_template-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
27*bcb5dc79SHONG Yifan| <a id="expand_template-out"></a>out |  The destination of the expanded file.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
28*bcb5dc79SHONG Yifan| <a id="expand_template-substitutions"></a>substitutions |  A dictionary mapping strings to their substitutions.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required |  |
29*bcb5dc79SHONG Yifan| <a id="expand_template-template"></a>template |  The template file to expand.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
30*bcb5dc79SHONG Yifan
31*bcb5dc79SHONG Yifan
32