bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

whitespaces #93

Closed punund closed 11 years ago

punund commented 12 years ago

I find it very difficult to insert trailing whitespaces into element's content:

    span price: 
    input(type='text')

I would like it to render as

    <span>price: </price><input type="text">

Trailing spaces are, however, get truncated. Jade, on the other hand, preserves them.

bminer commented 12 years ago

That doesn't sound right to me. Blade also preserves trailing whitespace. :)

And... it also preserves leading whitespace.

span testing (that's "span", followed by two spaces, followed by "testing") renders to:

<span> testing</span>
punund commented 12 years ago

Your are right. My bad.

bminer commented 12 years ago

No problem.

punund commented 11 years ago

Maybe it's unrelated, but how do I put a whitespace between elements:

input(type="text")
input(type="text")

result is

<input type="text"><input type="text">

desired

<input type="text"> <input type="text">

In Bootstrap controls get glued together...

bminer commented 11 years ago

That's an easy one. :)

input(type="text")
|  
input(type="text")

Notice that after the pipe character |, there are two spaces. A bit tricky, but I've gotten used to it.

punund commented 11 years ago

Well yes, I just thought that maybe it's worthwhile to have a shorthand notation, given that this is quite common, saving the line for just one whitespace:

input+(type="text")

Or whatever looks better. Besides, trailing spaces are already not too easy to notice, let alone to count them. I have to squint, personally.

bminer commented 11 years ago

Hmmm... you have a good point. So, your suggested solution is to follow tag names with a + to append a trailing space to the element. Is that correct? If so, I must ask... according to the XML spec, can element names contain plus characters? And, are you sure about a plus sign? IMHO, it looks just as strange as the pipe character and two spaces.

I'm open to ideas. Any thoughts on this?

punund commented 11 years ago

Plus characters can not be in an XML tag. I don't insist on this notation. Maybe > is a better choice, with cultural reference to HAML, and this certainly cannot be perceived as a part of the name. This may look as strange as the pipe, but it won't take up extra line, and won't make us wonder how many spaces there are after each standalone pipe.

Blade is so great at saving keystrokes, but here it forces 3 symbols and a line feed to denote just one space. I believe that the pipe should introduce some meaningful text, and this just looks like a hack.

bminer commented 11 years ago

Alright. I'll create a separate issue for this.

bminer commented 11 years ago

Er... no I won't. I'll just re-open this one and re-tag it. Thanks!

bminer commented 11 years ago

By the way, > is what I will use if HAML uses that. Thanks for doing some research on this.

bminer commented 11 years ago

@punund - Thanks for the suggestion! Checkout https://github.com/bminer/node-blade#whitespace-between-tags

punund commented 11 years ago

:clap: