diff --git a/lib/utopia/content/markup.rb b/lib/utopia/content/markup.rb index 85beebc4..6d355ec8 100644 --- a/lib/utopia/content/markup.rb +++ b/lib/utopia/content/markup.rb @@ -153,7 +153,7 @@ def instruction(string) end def cdata(string) - @delegate.text(string[9..-4]) + @delegate.write(string[9..-4]) end def text(string) diff --git a/test/utopia/.content/script/cdata.xnode b/test/utopia/.content/script/cdata.xnode new file mode 100644 index 00000000..f8ee1238 --- /dev/null +++ b/test/utopia/.content/script/cdata.xnode @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/test/utopia/.content/script/importmap.xnode b/test/utopia/.content/script/importmap.xnode new file mode 100644 index 00000000..6910bce2 --- /dev/null +++ b/test/utopia/.content/script/importmap.xnode @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/test/utopia/content.rb b/test/utopia/content.rb index ebfff43e..3bbf6b03 100755 --- a/test/utopia/content.rb +++ b/test/utopia/content.rb @@ -47,6 +47,32 @@ expect(last_response.body).to be == '10' end + it "should generate valid importmap" do + get "/script/importmap" + + expect(last_response.body).to be == <<~IMPORTMAP.chomp + + IMPORTMAP + end + + it "should generate valid javascript" do + get "/script/cdata" + + # We are expected to generate HTML... there is no good convention for "escaping javascript" in HTML. So we just plonk it in, verbatim. Yay. + expect(last_response.body).to be == <<~JAVASCRIPT.chomp + + JAVASCRIPT + end + it "should successfully redirect to the foo page" do get '/content/redirect' diff --git a/test/utopia/content/markup.rb b/test/utopia/content/markup.rb index 2c7aaed1..9b0dbf2c 100644 --- a/test/utopia/content/markup.rb +++ b/test/utopia/content/markup.rb @@ -58,7 +58,7 @@ def parse(string) [:tag_begin, foo_tag], [:text, "Bob & Barley"], [:write, ""], - [:text, "Hello & World"], + [:write, "Hello & World"], [:tag_end, foo_tag], ]