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

FR: macro to trim whitespaces around #383

Open
milo opened this issue Nov 1, 2024 · 0 comments
Open

FR: macro to trim whitespaces around #383

milo opened this issue Nov 1, 2024 · 0 comments

Comments

@milo
Copy link
Member

milo commented Nov 1, 2024

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>
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

No branches or pull requests

1 participant