Skip to content

FR: macro to trim whitespaces around #383

@milo

Description

@milo

Multiple whitespace characters in HTML text nodes are rendered as a single space. Would be useful to do not render it at all in some cases. For example in imaginary wiki page footer:

<footer>
    Version {$ver}
    created by {$author}
    {ifset $category}(in category {$category}{/}.
</footer>

If $category is not set, extrace space is rendered by browser before dot.

Version 1 created by Milo .

To solve that I use this formatting but it makes code and commits harder to read:

<footer>
    Version {$ver}
    created by {$author}{ifset $category}
    (in category {$category}{/}.
</footer>

Some macro like {trim} or unpaired version of {spaceless} would be usesul. Such macro would delete all whitespace-only text nodes around itself.

note: In case of trim, optional charlist could be provided, like {trim ":, \n"}.

An example above could look like:

<footer>
    Version {$ver}
    created by {$author} {trim}
    {ifset $category}
         (in category {$category}) {trim}
    {/}.
</footer>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions