templating
This module provides template rendering capabilities using Go's text/template package.It supports loading templates from local files or HTTPS URLs, and accepts variables
from YAML files or command-line parameters.
Templates can use any file extension, with optional .tmpl suffix that will be
automatically removed in the output. Variables can be provided via a YAML file,
command-line key=value pairs, or both (command-line takes precedence).
The module can be called from the dagger CLI or from any of the Dagger SDKs.
Installation
dagger install github.com/stuttgart-things/dagger/templating@v0.48.0Entrypoint
Return Type
Templating Example
dagger -m github.com/stuttgart-things/dagger/templating@5688fc36f6b8683f480bd79807bdd4d95e41545b call \
func (m *MyModule) Example() *dagger.Templating {
return dag.
Templating()
}@function
def example() -> dagger.Templating:
return (
dag.templating()
)@func()
example(): Templating {
return dag
.templating()
}Types
Templating 🔗
renderFromFile() 🔗
RenderFromFile renders Go templates with data loaded from a YAML or JSON file templates: comma-separated list of template paths (local in src or HTTPS URLs) dataFile: path to YAML or JSON file containing template data (file extension determines format) strictMode: if true, fail on missing variables; if false, render as “” (default: false)
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | No description provided |
| templates | String ! | - | No description provided |
| dataFile | String ! | - | No description provided |
| strictMode | Boolean | - | No description provided |
Example
dagger -m github.com/stuttgart-things/dagger/templating@5688fc36f6b8683f480bd79807bdd4d95e41545b call \
render-from-file --src DIR_PATH --templates string --data-file stringfunc (m *MyModule) Example(src *dagger.Directory, templates string, dataFile string) *dagger.Directory {
return dag.
Templating().
RenderFromFile(src, templates, dataFile)
}@function
def example(src: dagger.Directory, templates: str, data_file: str) -> dagger.Directory:
return (
dag.templating()
.render_from_file(src, templates, data_file)
)@func()
example(src: Directory, templates: string, dataFile: string): Directory {
return dag
.templating()
.renderFromFile(src, templates, dataFile)
}render() 🔗
RenderTemplates renders Go templates with provided variables templates: comma-separated list of template paths (local in src or HTTPS URLs) variables: comma-separated list of key=value pairs (e.g., “name=John,age=30”) variablesFile: optional YAML file with variables (variables parameter has higher priority) strictMode: if true, fail on missing variables; if false, render as “” (default: false)
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | No description provided |
| templates | String ! | - | No description provided |
| variables | String | - | No description provided |
| variablesFile | String | - | No description provided |
| strictMode | Boolean | - | No description provided |
Example
dagger -m github.com/stuttgart-things/dagger/templating@5688fc36f6b8683f480bd79807bdd4d95e41545b call \
render --src DIR_PATH --templates stringfunc (m *MyModule) Example(src *dagger.Directory, templates string) *dagger.Directory {
return dag.
Templating().
Render(src, templates)
}@function
def example(src: dagger.Directory, templates: str) -> dagger.Directory:
return (
dag.templating()
.render(src, templates)
)@func()
example(src: Directory, templates: string): Directory {
return dag
.templating()
.render(src, templates)
}