Skip to content

Allow writing into the wrapped IO #26

@willhbr

Description

@willhbr

This is useful if you want to embed an ECR template, read a file, etc into the Builder without creating an intermediate string.

I've got WIP code here but I'm not sure if the API could be improved.

How I think this should work is there are two methods, one gives access to the IO directly for writing HTML, and another gives access to a wrapped IO that pipes the input through HTML.escape first. This is a pattern I've used before.

The most natural API to me would be to allow passing a block to text and html instead of a string argument, but html(&block) is already defined to create an <html> tag.

What I've got currently is text(escaping : Bool = true, &block) which is fine. If someone else has another idea of how this could be done without conflicting with the html tag method, I'll happily change my implementation.

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