pub fn escape_quotes(s: &str, context: EscapeContext) -> StringExpand description
Escape a string for use in a single-quoted string literal in the target language.
This handles language-specific quote character escaping and necessary backslash escaping. The result can be safely embedded in a single-quoted string of the target language.
§Arguments
s- The string to escapecontext- The target language context
§Returns
A string with appropriate escape sequences for the target language’s single-quoted strings
§Examples
use spikard_cli::codegen::common::escaping::{EscapeContext, escape_quotes};
// Escape for PHP single-quoted strings
assert_eq!(escape_quotes("path\\to\\file", EscapeContext::Php), "path\\\\to\\\\file");
assert_eq!(escape_quotes("it's", EscapeContext::Php), "it\\'s");
// Escape for Ruby single-quoted strings
assert_eq!(escape_quotes("it's", EscapeContext::Ruby), "it\\'s");