Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Pretty mode and whitespaces #594

Closed
PeterMozesMerl opened this issue Mar 9, 2015 · 6 comments
Closed

Feature request: Pretty mode and whitespaces #594

PeterMozesMerl opened this issue Mar 9, 2015 · 6 comments

Comments

@PeterMozesMerl
Copy link

As far as I understood Slim adds whitespaces in pretty mode "only where it doesn’t matter". This is true unless you are using CSS to change display defaults.

Look at the following code:

          div 1
          div 2
          div 3
          span 1
          span 2
          span 3
          div style="display: inline-block" 1
          div style="display: inline-block" 2
          div style="display: inline-block" 3

The first and the second series of numbers are rendered the same way in development and in production mode. (Compared to themselves of course. The divs will be rendered in new lines and the spans will be rendered in a single line.)

The third series aren’t rendered the same way. There will be a space between them in development.

This makes the pretty mode more or less useless as soon as you have a layout with inline-block elements. Which is completely valid and sometimes better than having floating elements. I am not aware of any other solution than turning off pretty in development mode. (However, I am new to Slim).

It depends on the specific layout how much a small space will break it, but speaking about design more than zero difference is usually too much.

Since Slim can’t tell which elements’ displays are changed from the default, the solution might be to add an option to tell Slim "Please, do not add white spaces after this tag whatever you think about it. Thank you."

What do you think?

@tordans
Copy link

tordans commented Mar 13, 2015

Hi @PeterMozesMerl I believe we ran into the same problem.
We updated from Slim 2.1 to 3.0.1 a few days ago an only now figured out that the default behavior for intending changed between those versions.

We customized the config for our development Env now so it will behave like Staging/Production again. But I want to point out that it is highly annoying when I cannot rely on my Dev-Env to behave the same way as my Production Env.

In our case the layout for an important part of the website broke in Dev because we use display: inline-block and display: inline.

In my opinion the default config should be change again so all Envs behave the same way. Which would be the (sometimes annoying) slim-way to remove all whitespaces everywhere except for when I tell it not to (with <>).

Tobias

@minad
Copy link
Member

minad commented Mar 13, 2015

@tordans Please ask slim-rails to change it back or create a short poll there.

@phlegx
Copy link

phlegx commented Apr 29, 2015

@tordans I have the same problem using Slim::Engine.set_default_options pretty: true in production. Option pretty removes well defined spaces using < or >. Any idea how to solve this problem?

@tordans
Copy link

tordans commented May 1, 2015

@phlegx we just reset the option in our app so all environments behave the same.
Please "+1" my issue at slim-template/slim-rails#87 to the defaults get changed again, so not more people are annoyed.

@minad
Copy link
Member

minad commented May 22, 2015

I deactivated it again in slim-rails master.

@minad minad closed this as completed May 22, 2015
@tordans
Copy link

tordans commented Dec 26, 2015

(Comment edited)
@minad sorry, nevermind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants