Skip to content

Feature request: Provide a way to skip outputting whitespace #101

@landyacht

Description

@landyacht

Because browsers add space between certain elements when there is space around their tags in the HTML, sometimes writing raw HTML you'd do something like this:

<p> To learn more, click <a href="...">this link</a>. </p>

Note the lack of whitespace between the ending anchor tag and the punctuation.

However, when generating HTML via a Cro template, getting this effect becomes unwieldy. Consider the following:

<p>
    <@.elements>
        <?{ .type eq 'text' }>
            <.text>
        </?>
        <!?{ .type eq 'link' } a href="<.target>">
            <.link-text>
        </?>
    </@>
</p>

To have punctuation immediately next to an anchor tag, we'd have to scrunch this code mostly onto one line. Otherwise, the spacing in the source crotmp file gets preserved in the generated HTML. Might I suggest a backslash to render any amount of following whitespace "insignificant"?

        <!?{ .type eq 'link' } a href="<.target>">\
            <.link-text>\
        </?>\

Some kind of "auto-minify" setting on the template render call might be nice as well, but less granular.

Metadata

Metadata

Assignees

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