aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2023-10-21 17:15:09 +0100
committerHayleigh Thompson <me@hayleigh.dev>2023-10-21 17:15:09 +0100
commit728041fb5adf33b2db33d3fcf7e5988887eca7cf (patch)
tree72530800417b07cecab58214d2748364a5546939
parentdbf232acb059f9f3f8972242b68a9384b1290dd4 (diff)
downloadlustre-728041fb5adf33b2db33d3fcf7e5988887eca7cf.tar.gz
lustre-728041fb5adf33b2db33d3fcf7e5988887eca7cf.zip
:recycle: Hide the 'raw_text' parameter from string builder.
-rw-r--r--src/lustre/element.gleam13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lustre/element.gleam b/src/lustre/element.gleam
index f4fd321..aafd78f 100644
--- a/src/lustre/element.gleam
+++ b/src/lustre/element.gleam
@@ -84,12 +84,19 @@ pub fn map(element: Element(a), f: fn(a) -> b) -> Element(b) {
///
pub fn to_string(element: Element(msg)) -> String {
- to_string_builder(element, False)
+ to_string_builder_helper(element, False)
|> string_builder.to_string
}
+pub fn to_string_builder(element: Element(msg)) -> StringBuilder {
+ to_string_builder_helper(element, False)
+}
+
///
-pub fn to_string_builder(element: Element(msg), raw_text: Bool) -> StringBuilder {
+pub fn to_string_builder_helper(
+ element: Element(msg),
+ raw_text: Bool,
+) -> StringBuilder {
case element {
Text(content) if raw_text -> string_builder.from_string(content)
Text(content) -> string_builder.from_string(escape("", content))
@@ -176,5 +183,5 @@ fn children_to_string_builder(
raw_text: Bool,
) -> StringBuilder {
use html, child <- list.fold(children, html)
- string_builder.append_builder(html, to_string_builder(child, raw_text))
+ string_builder.append_builder(html, to_string_builder_helper(child, raw_text))
}