Skip to content

Whitespace control #29

@kornelski

Description

@kornelski

I have a couple of places in HTML where I want to prevent any extra whitespace in the generated output:

  • When generating multiple inline or inline-block elements that shouldn't have gaps created by spaces.
  • When inserting commas or periods after elements, since a space before punctuation marks is generally inappropriate typographically.

Currently I'm just writing templates without spaces in them, but this isn't very convenient, since it requires use of long lines, and careful avoidance of any spaces.

@if let Some(url) = url.author(a) {
    <a href="@url"><span>@a.name()</span></a>@if !last {,} else {.}
}
<span class="version">@d.dep.req()</span>@for f in d.dep.req_features() {<span class="with-feature"><wbr>+<span>@f</span></span>}

So ideally I'd like some kind of block/directive that allows me to write template source with line breaks and indentation as usual, but remove that whitespace from the output.

I'm not sure what the syntax for it should look like, but generally template languages have blocks that either ignore all whitespace around elements, or trim whitespace at beginning and end of every line.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions