tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.
https://j2html.com/
Apache License 2.0
765 stars 136 forks source link

Multiline titles using 
 #217

Closed wowselim closed 1 year ago

wowselim commented 2 years ago

Is there an easy way to create title attributes with multiple lines?

Here's an example of what I'm trying to do: https://jsfiddle.net/hvn8o19t/

I couldn't find a way to pass this as an attribute to j2html without it being escaped.

sembler commented 2 years ago

It doesn't look like you need to do anything special to have a newline in the attribute text. Everywhere that I've tried, it worked by using a newline literal instead of 
.

Example:

div().withTitle("Line 1\nLine 2")

produces

<div title="Line 1
Line 2">Secret</div>

which rendered to two lines when the mouse hovered over the div.

wowselim commented 2 years ago

That does work indeed. It' weird because it's the only newlines when viewing the page source but I'm fine with that since it works 🤷