leaf-kit icon indicating copy to clipboard operation
leaf-kit copied to clipboard

Add support for minification or prettification of Leaf's final output

Open tonyarnold opened this issue 4 years ago • 1 comments

I'm finding that the default output of a readable Leaf template includes quite a lot of unnecessary whitespace. To combat this, I'm reducing the "real" whitespace in my Leaf templates, but it's making them unreadable.

It would be great if Leaf could be told to ignore whitespace in certain contexts, or better yet, if Leaf supported minification/prettification of it's output.

tonyarnold avatar Jan 19 '22 04:01 tonyarnold

The Swift Stencil template language has a similar feature when setting trimBehavior to .smart or .all.

        let environment = Stencil.Environment(
            loader: FileSystemLoader(paths: [Path(templatesPath)]),
            extensions: [ext],
            trimBehaviour: .smart
        )

I would prefer this technique so Leaf can render formats like Markdown or Asciidoc more cleanly. I'm rendering these formats with Leaf and it works great for the most part, but it would be nice to trim the extra whitespace around block declarations.

esummers avatar Sep 25 '22 02:09 esummers