Spaces in html select options
css, html, symfony, twig
Solution
The problem here is that Twig will automatically escape HTML entities (calling `htmlspecialchars`, effectively). Since you want to send a literal string of HTML, you don't want the automatic escaping to be done.
Now, you haven't provided your Twig code, so I can't say exactly how you should do this. But my guess is that you're including it with something like this:
{{ table.column }}
You need to use the `raw` filter:
{{ table.column | raw }}
You do need to be careful here, though. If the values in the column can come from a user, you're opening yourself up to an XSS attack.
Problem
I want to make something like this: ``` <select> <option>Column1abc Column2klmn Column3</option> <option>Column1defgh Column2opr Column3</option> <option>Column1ij Column2stuvwxyz Column3</option> </select> ``` with `<style>select option { font-family: courier;} </style>` But the rendered result is without multiple spaces. If I use ` ` instead of "``", I get ` ` as string, not as non-breaking space. How can I fix that?