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

implement whitespace removal for Diet templates #362

Merged
merged 1 commit into from
Oct 26, 2013
Merged

implement whitespace removal for Diet templates #362

merged 1 commit into from
Oct 26, 2013

Conversation

japplegame
Copy link
Contributor

Haml syntax: http://haml.info/docs/yardoc/file.REFERENCE.html#whitespace_removal__and_
and more Jade-like Scalate syntax: http://scalate.fusesource.org/documentation/jade-syntax.html#Whitespace_Removal:__code__gt___code__and__code__lt___code_

I think this is really useful feature.

It is compile time implementation, so removing whitespace inside runtime constructions (like if or foreach) works, but a little weird.

For example:

div<
    - foreach(i; [1, 2, 3])
        img

generates

<div><img/><img/><img/></div>

but not expected

<div><img/>
    <img/>
    <img/></div>

because < removes whitespace before img tag, and foreach repeats it 3 times already without whitespace.

@s-ludwig
Copy link
Member

Nice, this would also solve issue #244. I'll make a detailed review later, but (even though it reverses how Jade does things) I like how this approach keeps the HTML output tidy in general. Do you have time to add a short paragraph with some examples in https://github.com/rejectedsoftware/vibed.org/blob/master/views/templates.dt? I would really appreciate that, but if not, I'll allocate some time for that later on.

@japplegame
Copy link
Contributor Author

By default, Jade inserts indentation everywhere, excluding spans.
Finally Diet is not Jade and IMO It's not necessarily exactly follow all things.

My English is rather bad, but I'll try to add a description.

@s-ludwig
Copy link
Member

Hm okay, so now with your changes we could also easily make stripping whitespace around <span> the default.

However, I see it similar, that we don't have to follow everything exactly. And apart from <span>, there can be many other cases, where no whitespace is desirable, for example for a link that is directly followed by a full stop, so I'm for keeping things simple and requiring the >< syntax in all cases (or inline-HTML).

Code looks well btw., will merge.

s-ludwig added a commit that referenced this pull request Oct 26, 2013
implement whitespace removal for Diet templates
@s-ludwig s-ludwig merged commit 8585338 into vibe-d:master Oct 26, 2013
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

Successfully merging this pull request may close these issues.

2 participants