quoteComment function

String quoteComment(
  1. String text, [
  2. bool includeDelimiters = false
])

Escape comment end delimiters in a string, optionally wrapping in unescaped comment delimiters.

Implementation

String quoteComment(String text, [bool includeDelimiters = false]) {
	// escape
	var result = text.replaceAll("#>", "\\#>");
	// delimit
	if (includeDelimiters) {
		result = "<# $result #>";
	}
	// return
	return result;
}