Avoiding whitespace between tags in Jade template output when pretty printing
Asked Answered
C

1

7

I have to print out an input tag and a label without any space between the end of one tag and the start of the next... but I also want to pretty-print the rest of the document.

By default — with pretty printing turned on in Jade — I get the following:

<input ...></input>
<label ...></label>

I want:

<input ...><label ...></label>

or

<input ...></input><label ...></label>

The idea from Jade - Controlling line-breaks in the HTML output doesn't work because input is a self-closing tag.

Update 1: I have created the obvious solution using a mixin and literal HTML, but I would like to avoid that if possible.

Caladium answered 10/10, 2015 at 5:36 Comment(1)
If it's possible to break it into multiple files, you could perhaps make that part a separate file then use the API to turn off pretty for the file(s) that contain that line. You could try post-processing the HTML file to get the desired results. In either case, I'm not sure it would be worth the trouble.Nanete
S
1

In Razor, I addressed this by wrapping the whitespace with a multi-line comment:

    <div>
        <span>No trailing</span><!--
     --><span>space</span>
    </div>
Sexpot answered 14/1, 2016 at 17:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.