I am noticing a lot of extra blank lines for the lines where my template logic exists. I notice this mostly when I'm building javascript.

How do I go about preventing this?


//do some stuff here

will output:


//do some stuff here

  • Is this causing an actual implementation issue?
    – jrothafer
    Oct 22 '15 at 0:49
  • 2
    Sometimes you have to choose between seeing pretty template code and pretty output code. :-)
    – AllInOne
    Oct 22 '15 at 16:10
  • I concur, @AllInOne. I guess pretty template code for now is the winner and I won't let my irritations about it get in my way :)
    – kambythet
    Oct 22 '15 at 20:34

I've seen this. I think it's because the line breaks for {exp...}, {datablock} and so forth are added to the source, even if the code on those lines doesn't insert anything visibly into the page. It really kind of makes sense, when you think about it, although it definitely makes for less clean-looking source code, and marginally more HTML data that has to be sent to the browser.

If this is really an issue to you, you could use Minimee to minify your HTML. That will get rid of the line breaks, but will butcher the readability of your source.

  • To minify HTML on the fly isn't a good idea. You can make your site slower.
    – Sobral
    Oct 22 '15 at 2:53
  • To use template comments can be an option, too. Add them to your answer: {!-- --}.
    – Sobral
    Oct 22 '15 at 2:54
  • It does make sense. Since each {..} essentially converts to <?php ... ?> and since I'm putting them on different lines, then the output will include the new lines between ?> and <?php. It's not necessarily a problem outside of my OCD getting in the way when I see all the space it adds making the code look not as clean :)
    – kambythet
    Oct 22 '15 at 20:31
  • Robson, I've never noticed a slowdown from using Minimee, although I suppose "YMMV" could apply. Regarding template comments, I'm not sure how adding them would help in this situation, unless you mean starting them at the end of each line and ending them at the beginning of the next line?
    – Matthew
    Oct 26 '15 at 16:51

Depending on how your script is working, you may need to escape the "{}" around the EE tags. I've only ran into this a couple of times. What does the inspector tell you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.