`textarea` whitespace

#33 · closed · 4 comments

View on GitHub ↗

khanlou

By default, the `textarea` tag uses all the whitespace inside of it and uses that for the value of the textarea. Since Swim's default approach for rendering an html tree to a string is to pretty print it with tons of whitespace (which in general is great!), this adds a bunch of whitespace in any textarea. I'm not sure what the best way to fix this is: 1. Special case textarea's printing? 2. Have a printing mode that prints with no extra whitespace? 3. Add another parameter to textarea for its value?

Comments

robb

(This issue got lost in my inbox somehow, apologies) Just to double check, the whitespace you are talking about is the one highlighted with `¬` and `·` here: ```swift textarea { """ Hello World """ } ``` ```html <textarea>¬ ····Hello World¬ <textarea> ``` if that's the case, it should be enough to give the `textarea` definition a `trim whitespace` attribute similar to `textLevelSemantics`. In the short term, you can wrap your contents with a trim operator: ```swift textarea { %""" Hello World """% } ``` which should give you ```html <textarea>Hello World<textarea> ```

khanlou

Oh, this is perfect. This unlocked it for me: ``` textarea(cols: "30", name: "notes", rows: "4") { Node.trim item.notes Node.trim } ```

robb

Should be better in `main`.

khanlou

Looks wonderful, thank you!