`
+ el := Raw(rawHTML)
+ expected := rawHTML
+
+ assert.Equal(t, expected, el.Render())
+}
From 4ee51fcd4c99641419a1fddb7528b7b1e1ba7868 Mon Sep 17 00:00:00 2001
From: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
Date: Tue, 21 Nov 2023 08:36:18 -0800
Subject: [PATCH 2/3] Add `Raw` to README
---
README.md | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4ecc0d2..e5d107d 100644
--- a/README.md
+++ b/README.md
@@ -148,7 +148,23 @@ In this example, if `isAdmin` is `true`, the `Admin Panel` link is rendered. Oth
- **Script-supporting Elements**: `Script`, `Noscript`
- **Inline Semantic**: `A`, `Strong`, `Em`, `Code`, `I`
-### Additional Utility: HTML Comments
+### Raw HTML Insertion
+
+The `Raw` function allows for the direct inclusion of raw HTML content within your document structure. This function can be used to insert HTML strings, which will be rendered as part of the final HTML output.
+
+```go
+rawHTML := `
Custom HTML content
`
+content := elem.Div(nil,
+ elem.H1(nil, elem.Text("Welcome to Elem-Go")),
+ elem.Raw(rawHTML), // Inserting the raw HTML
+ elem.P(nil, elem.Text("More content here...")),
+)
+
+htmlOutput := content.Render()
+// Output:
Welcome to Elem-Go
Custom HTML content
More content here...
+```
+
+### HTML Comments
Apart from standard elements, `elem-go` also allows you to insert HTML comments using the `Comment` function:
From c16877c4041af01e1760b79bf85a45a55eeee411 Mon Sep 17 00:00:00 2001
From: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
Date: Tue, 21 Nov 2023 08:47:56 -0800
Subject: [PATCH 3/3] Add note
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index e5d107d..0f53b3d 100644
--- a/README.md
+++ b/README.md
@@ -163,6 +163,7 @@ content := elem.Div(nil,
htmlOutput := content.Render()
// Output:
Welcome to Elem-Go
Custom HTML content
More content here...
```
+> **NOTE**: If you are passing HTML from an untrusted source, make sure to sanitize it to prevent potential security risks such as Cross-Site Scripting (XSS) attacks.
### HTML Comments