git.delta.rocks / jrsonnet / refs/commits / 54c4db58ad3d

difftreelog

source

crates/jrsonnet-stdlib/src/manifest/mod.rs1.2 KiBsourcehistory
1mod yaml;23use jrsonnet_evaluator::{4	error::Result,5	function::builtin,6	manifest::{escape_string_json, JsonFormat},7	typed::Any,8	IStr,9};10pub use yaml::YamlFormat;1112#[builtin]13pub fn builtin_escape_string_json(str_: IStr) -> Result<String> {14	Ok(escape_string_json(&str_))15}1617#[builtin]18pub fn builtin_manifest_json_ex(19	value: Any,20	indent: IStr,21	newline: Option<IStr>,22	key_val_sep: Option<IStr>,23	#[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,24) -> Result<String> {25	let newline = newline.as_deref().unwrap_or("\n");26	let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");27	value.0.manifest(JsonFormat::std_to_json(28		indent.to_string(),29		newline,30		key_val_sep,31		#[cfg(feature = "exp-preserve-order")]32		preserve_order.unwrap_or(false),33	))34}3536#[builtin]37pub fn builtin_manifest_yaml_doc(38	value: Any,39	indent_array_in_object: Option<bool>,40	quote_keys: Option<bool>,41	#[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,42) -> Result<String> {43	value.0.manifest(YamlFormat::std_to_yaml(44		indent_array_in_object.unwrap_or(false),45		quote_keys.unwrap_or(true),46		#[cfg(feature = "exp-preserve-order")]47		preserve_order.unwrap_or(false),48	))49}