Skip to content

Commit 0e04720

Browse files
author
Max Dymond
committed
Instead of {yaml|json|toml}load, just use {yaml|json|toml}
Signed-off-by: Max Dymond <max.dymond@microsoft.com>
1 parent 80248c3 commit 0e04720

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Status: Available for use
1414
### Breaking Changes
1515

1616
### Added
17-
- Add `yamlload` function to tera templating engine so that floki templates
18-
can use `yamlload(file="<filepath>")` in order to load values.
19-
- Add `jsonload` function to tera templating engine so that floki templates
20-
can use `jsonload(file="<filepath>")` in order to load values.
21-
- Add `tomlload` function to tera templating engine so that floki templates
22-
can use `tomlload(file="<filepath>")` in order to load values.
17+
- Add `yaml` function to tera templating engine so that floki templates
18+
can use `yaml(file="<filepath>")` in order to load values.
19+
- Add `json` function to tera templating engine so that floki templates
20+
can use `json(file="<filepath>")` in order to load values.
21+
- Add `toml` function to tera templating engine so that floki templates
22+
can use `toml(file="<filepath>")` in order to load values.
2323
- Add `floki render` to print out the rendered configuration template.
2424

2525
### Fixed

src/config.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ pub fn render_template(template: &str, source_filename: &Path) -> Result<String,
135135
let mut tera = Tera::default();
136136

137137
// Allow templates to load variables files as Values.
138-
tera.register_function("yamlload", yamlloader);
139-
tera.register_function("jsonload", jsonloader);
140-
tera.register_function("tomlload", tomlloader);
138+
tera.register_function("yaml", yamlloader);
139+
tera.register_function("json", jsonloader);
140+
tera.register_function("toml", tomlloader);
141141

142142
tera.add_raw_template(&template_path, template)
143143
.map_err(|e| errors::FlokiError::ProblemRenderingTemplate {
@@ -324,15 +324,17 @@ mod test {
324324

325325
#[test]
326326
fn test_tera_yamlload() -> Result<(), Box<dyn std::error::Error>> {
327-
let template = r#"{% set values = yamlload(file="test_resources/values.yaml") %}shell: {{ values.foo }}"#;
327+
let template =
328+
r#"{% set values = yaml(file="test_resources/values.yaml") %}shell: {{ values.foo }}"#;
328329
let config = render_template(template, Path::new("floki"))?;
329330
assert_eq!(config, "shell: bar");
330331
Ok(())
331332
}
332333

333334
#[test]
334335
fn test_tera_jsonload() -> Result<(), Box<dyn std::error::Error>> {
335-
let template = r#"{% set values = jsonload(file="test_resources/values.json") %}shell: {{ values.foo }}"#;
336+
let template =
337+
r#"{% set values = json(file="test_resources/values.json") %}shell: {{ values.foo }}"#;
336338
let config = render_template(template, Path::new("floki"))?;
337339
assert_eq!(config, "shell: bar");
338340
Ok(())
@@ -341,7 +343,7 @@ mod test {
341343
#[test]
342344
fn test_tera_tomlload() -> Result<(), Box<dyn std::error::Error>> {
343345
let template =
344-
r#"{% set values = tomlload(file="Cargo.toml") %}floki: {{ values.package.name }}"#;
346+
r#"{% set values = toml(file="Cargo.toml") %}floki: {{ values.package.name }}"#;
345347
let config = render_template(template, Path::new("floki"))?;
346348
assert_eq!(config, "floki: floki");
347349
Ok(())

0 commit comments

Comments
 (0)