13 votes
Accepted

How do I get rid of whitespace when rendering without touching template indentations?

The spaceless tag only removes whitespace between HTML tags. You have to use the whitespace control modifier on your tags to remove leading and or trailing whitespace. Additionally I'd use the ...
user avatar
  • 35.8k
12 votes

Whitespace created when using if statements

You can also the hyphen/dash '-' modifier for shorter syntax and in place of the spaceless tags. Plus you get a bit more granular control where you want it, like trimming only leading or trailing ...
user avatar
  • 221
10 votes
Accepted

Whitespace created when using if statements

Have a look at the twig documentation regarding whitespace control: https://twig.symfony.com/doc/2.x/templates.html#whitespace-control In short, wrap the area where you want to remove whitespace in {...
user avatar
  • 7,228
5 votes
Accepted

.relatedTo() not returning tags with spaces

In your working example, you’re mapping request.tags to the search param, but in the non-working example, you’re mapping it to the slug param. Those two params are handled in very different ways. ...
user avatar
5 votes
Accepted

Unwanted output when using Twig conditional

I pasted your HTML into TextMate with “Show Invisible Characters” enabled, and it shows that there are two “zero width no-break space” (U+FEFF) characters in there, at the end of these lines: {% if ...
user avatar
4 votes

Whitespace created when using if statements

You have several different options, depending on what you want to do: The spaceless function, which removes whitespace between HTML tags: {% spaceless %} <div> <strong>foo<...
user avatar
  • 2,947
3 votes
Accepted

How do you prevent white space from being removed after line breaks within a Rich Text Field?

Unfortunately you can't really configure how Redactor formats it's input. Given this I think your current solution is the most effective. That said, you could try this alternative style for your <...
user avatar
3 votes
Accepted

Whitespace created a start of HTML

I finally found what the problem was. The translations files (/craft/translations/de.php) were encoded as "UTF-8 with BOM" I opened these files in Sublime text and saved them as regular old UTF-8, ...
user avatar
  • 301
2 votes

Whitespace created when using if statements

You could always just use the Minify plugin and wrap whatever you want in: {% minify %} {% endminify %} If works with inline CSS/JS, too.
user avatar
  • 10.9k
2 votes

Unwanted output when using Twig conditional

I'd venture to guess that you have a BOM character in there somewhere. It's basically an invisible character that does nothing but cause trouble. One of these can show up from copying a chunk of code ...
user avatar
  • 23.6k
2 votes
Accepted

White space added to start of template's

As Brad kindly pointed out, I checked my files in the config directory and noticed a few spaces before I started the <?php in my /craft/config/imager.php file. I would never have thought to check ...
user avatar
  • 671
1 vote
Accepted

Rich Text field is producing weird space character instead of &nbsp;

I did contact Craft about this near the time this question was posted, they were not sure why it was occuring. I found that this issue was environment specific, it was specifically happening locally ...
user avatar
  • 449
1 vote

How do you prevent white space from being removed after line breaks within a Rich Text Field?

Try HTML: <p class="rich-test">Line breaks were the first thought.<br class="hide-for-small show- for-large">Not an afterthought.</p> CSS: p.rich-text{ white-space: pre-line; }
user avatar
1 vote

How do you prevent white space from being removed after line breaks within a Rich Text Field?

Craft now has a "Clean up HTML?" checkbox on Rich Text fields (it's hidden under "Advanced" on the field edit page). I was having problems with Redactor removing whitespace (in my case it was extra ...
user avatar
  • 1,215

Only top scored, non community-wiki answers of a minimum length are eligible