Add Rawf (#114) Like `Raw`, but interpolates like `Textf`.
1 file changed, 15 insertions(+), 0 deletions(-)
changed files
M gomponents_test.go → gomponents_test.go
@@ -212,6 +212,21 @@ _ = e.Render(os.Stdout) // Output: <span><button onclick="javascript:alert('Party time!')">Party hats</button> > normal hats.</span> } +func TestRawf(t *testing.T) { + t.Run("renders interpolated and raw text", func(t *testing.T) { + e := g.Rawf("<%v>", "div") + assert.Equal(t, "<div>", e) + }) +} + +func ExampleRawf() { + e := g.El("span", + g.Rawf(`<button onclick="javascript:alert('%v')">Party hats</button> > normal hats.`, "Party time!"), + ) + _ = e.Render(os.Stdout) + // Output: <span><button onclick="javascript:alert('Party time!')">Party hats</button> > normal hats.</span> +} + func TestGroup(t *testing.T) { t.Run("groups multiple nodes into one", func(t *testing.T) { children := []g.Node{g.El("br", g.Attr("id", "hat")), g.El("hr")}