v0.2.0
Pre-release
Pre-release
Highlights
Conditional rendering
It's possible to override #render?
method to control blueprint render.
class Example
include Blueprint::HTML
private def blueprint
h1 { "Example" }
end
private def render?
false
end
end
example = Example.new
example.to_html # => ""
Array attributes
Arrays passed as attribute values will be flattened and joined with " "
.
class Example
include Blueprint::HTML
private def blueprint
h1(class: ["a", "b", ["c", "d"]) { "Example" }
end
end
example = Example.new
example.to_html # => "<h1 class="a b c d">Example</h1>"
Enveloping
By overriding the #envelope(&)
method, you can create a wrapper around blueprint content. This is useful when defining layouts for pages
class Layout
include Blueprint::HTML
private def blueprint(&)
html do
body do
yield
end
end
end
end
class BasePage
include Blueprint::HTML
private def envelope(&)
render(Layout.new) { yield }
end
end
class Example < BasePage
def blueprint
h1 { "Example" }
end
end
example = Example.new
example.to_html # => "<html><body><h1>Hello</h1></body></html>"
Log
- config: Config linter by @stephannv in #24
- config: Add last 3 crystals versions to CI by @stephannv in #25
- feat: Allow conditional rendering by @stephannv in #26
- config: Reorganize CI by @stephannv in #27
- refactor: Clean up code by @stephannv in #28
- docs: Add CHANGELOG.md by @stephannv in #29
- test: Fix newline gsub by @stephannv in #31
- refactor: Minor code refactor by @stephannv in #32
- feat: Handle array attributes by @stephannv in #33
- config: Caching shards on CI by @stephannv in #34
- docs: Add struct usage to README by @stephannv in #35
- feat: Add
envelope(&)
method by @stephannv in #36 - docs: Mention generics to handle multiple layouts by @stephannv in #37
Full Changelog: v0.1.0...v0.2.0