Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jade - Controlling line-breaks in the HTML output

I have a simple search form I wish to implement using Jade.

form
    input(
        type="text"
        size="16"
        placeholder="Enter your keywords")
    input(
        type="button"
        value="Search")

The output is rendered as:

<form>
      <input type="text" size="16" placeholder="Enter your keywords">
      <input type="button" value="Search">
</form>

This is perfect except that the line-break is causing a space between my button and the search button. I need no space between the textbox and the button. I need the code to render like this:

<form>
      <input type="text" size="16" placeholder="Enter your keywords"><input type="button" value="Search">
</form>

However I am using this project to create code that will need to be read in its HTML form, and can't simple remove white space from my project as a whole.

Is there a way I could output my form as indicated whilst retaining white spacing and line-breaking in the rest of my document?

like image 643
William Owen Avatar asked Aug 08 '12 14:08

William Owen


People also ask

Why do we need line breaks in HTML?

When you're writing HTML, you often need to insert line breaks. A line break is essential in addresses, poems, or when text exceeds the available browser width. If you don't insert your own line breaks, then the text gets formatted in an odd way.

How to remove line breaks in HTML using jsoup?

3. Preserving Line Breaks Associated with <br> and <p> Tags While cleaning the HTML text using the Jsoup#clean method, it removes the line breaks created by HTML tags like <br> and <p>. To preserve the line breaks associated with these tags, we first need to create a Jsoup Document from our HTML string:

What happens if you don't insert your own line breaks?

If you don't insert your own line breaks, then the text gets formatted in an odd way. In this tutorial, I'm going to show you how to insert line breaks in your HTML code with some "with and without" examples, so you can start using it correctly and format your text better.

What is the purpose of a line break in a poem?

A line break is essential in addresses, poems, or when text exceeds the available browser width. If you don't insert your own line breaks, then the text gets formatted in an odd way.


1 Answers

I was looking for the same thing and came across this: http://scalate.fusesource.org/documentation/jade-syntax.html

Under Plain text: Whitespace Removal: > and <

I was having an issue with whitespace inside an <a> tag:

a.external(href={"http://foo.bar/" + reference.dxLink.get})
  |CrossRef

resulted in

<a href="http://foo.bar/10.1002/rmv.439">
                  CrossRef
</a>

Adding < to the end of the line:

a.external(href={"http://foo.bar/" + reference.dxLink.get})<
  |CrossRef

resulted in

<a href="http://foo.bar/10.1002/rmv.439">CrossRef</a>
like image 123
Todd Carter Avatar answered Oct 02 '22 16:10

Todd Carter