hcl_primitives::template

Function escape_markers

Source
pub fn escape_markers(literal: &str) -> Cow<'_, str>
Expand description

Escapes interpolation sequence (${) and directive control flow (%{) start markers in a string literal to $${ and %%{ respectively.

use hcl_primitives::template::escape_markers;

assert_eq!(escape_markers("foo"), "foo");
assert_eq!(escape_markers("${interpolation}"), "$${interpolation}");
assert_eq!(escape_markers("$${escaped_interpolation}"), "$$${escaped_interpolation}");
assert_eq!(escape_markers("%{if foo}bar%{else}baz%{endif}"), "%%{if foo}bar%%{else}baz%%{endif}");