Params & asset URLs
:param and :assetUrl are text directives with a special behaviour: they are evaluated before Markdown is processed, so they resolve even inside code blocks and directive attributes. That is why every source block on this page escapes them as \:param / \:assetUrl - otherwise the source would show the resolved value instead of the literal directive.
:param injects a value defined under params in contentspec.yaml, so a repeated string, URL or number is defined once and referenced everywhere.
Properties: key (string, the param to display), defaultValue (string, shown if the key has no value).
This template's contentspec.yaml defines:
1
2
3
4
5
6
7
8
9
10
11
params:
name:
first: John
last: Doe
foo: Bar
awsBlogLink: https://aws.amazon.com/blogs/aws/
levels:
- 100
- 200
- 300
- 400Rendered:
The value of foo is Bar. Available levels: 100, 200, 300.
Source:
1
The value of `foo` is :param{key="foo"}. Available levels: :param{key=levels[0]}, :param{key=levels[1]}, :param{key=levels[2]}.Rendered:
Welcome John Doe!
Source:
1
Welcome :param{key=name.first} :param{key=name.last}!If the key has no value, defaultValue is shown instead.
Rendered:
The secret to life is 42.
Source:
1
The secret to life is :param{key=secretToLife defaultValue=42}.globals.baseUrl (ends in a trailing slash) and globals.locale are always available.
Rendered:
curl /buildsstatic/cf-templates/setup.yaml -s -o my.file
Source:
1
curl :param{key=globals.baseUrl}static/cf-templates/setup.yaml -s -o my.file:assetUrl renders an absolute, environment-correct URL for an asset. It is mainly used to embed a full asset URL inside a copy/paste command, where relative paths would not expand.
Properties: path (string, relative location of the asset), source (repo | s3, default repo). repo points at /static; s3 points at the uploaded assets bucket.
Wrap :assetUrl in single quotes inside shell commands so the shell does not interpret & in the signed URL.
Rendered:
1
curl '/builds/static/resources/template.yaml' --output template.yamlSource:
1
2
3
```bash
curl ':assetUrl{path="/resources/template.yaml"}' --output template.yaml
```Rendered:
1
curl '/builds/assets/resources/template.yaml' --output template.yamlSource:
1
2
3
```bash
curl ':assetUrl{path="/resources/template.yaml" source=s3}' --output template.yaml
```