diff --git a/elements.go b/elements.go index d37dc40..af540a7 100644 --- a/elements.go +++ b/elements.go @@ -525,3 +525,8 @@ func None() NoneNode { func Raw(html string) RawNode { return RawNode(html) } + +// CSS takes css content and returns a TextNode. +func CSS(content string) TextNode { + return TextNode(content) +} diff --git a/elements_test.go b/elements_test.go index 98bf2ca..426b968 100644 --- a/elements_test.go +++ b/elements_test.go @@ -327,7 +327,7 @@ func TestScript(t *testing.T) { func TestStyle(t *testing.T) { expected := `` cssContent := `.test-class {color: #333;}` - el := Style(attrs.Props{attrs.Type: "text/css"}, TextNode(cssContent)) + el := Style(attrs.Props{attrs.Type: "text/css"}, CSS(cssContent)) assert.Equal(t, expected, el.Render()) } @@ -680,3 +680,10 @@ func TestRaw(t *testing.T) { assert.Equal(t, expected, el.Render()) } + +func TestCSS(t *testing.T) { + cssContent := `.test-class {color: #333;}` + expected := `.test-class {color: #333;}` + el := CSS(cssContent) + assert.Equal(t, expected, el.Render()) +} diff --git a/styles/README.md b/styles/README.md index a997384..7069fa3 100644 --- a/styles/README.md +++ b/styles/README.md @@ -108,7 +108,7 @@ These functions facilitate the embedding of CSS into HTML documents, particularl cssContent := `/* ... */` // Creating a