Closed Reekoj closed 6 years ago
All text is escaped by default (to prevent XSS). You can use therawHtml()
method:
script(rawHtml("alert(\"hello world\");")).withType("text/javascript")
, but I'd probably flip it for readability:
script().withType("text/javascript").with(
rawHtml("alert('hello world');")
),
Ok it works, Thanks for the help (and for j2html btw that's great)
You're welcome (and thanks!)
Oh and i wanted to ask you something, sorry that's not related to this issue but i'm wondering why you say on your website that we shouldn't use j2html with Bootstrap ? because i tried with a simple w3school's example and it works http://prntscr.com/hylr61
@Reekoj it's fine if you want to do that, but Bootstrap has very verbose markup (a lot of lines of HTML per component). Normally you would just copy-paste the HTML from the bootstrap site, but you'll have to convert everything to j2html-code if you want to use it with j2html. If you use a template engine instead, you can just copy-paste the HTML directly into the template.
Hello, it's kind of a noob question but i can't find a way to render the quote symbol ? for example if i do that :
script("alert(\"hello world\");").withType("text/javascript")
the string rendered look like that :<script type="text/javascript">alert("hello world");</script>