Skip to content

v0.2.0

Release date: 2023.04.07

Added

Allow 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 # => ""

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

Adds #envelope(&) method

By overriding the #envelope(&) method, you can create a wrapper around blueprint content. This is useful when defining layouts for pages.

class Example
  include Blueprint::HTML

  private def blueprint
    h1 { "Example" }
  end

  private def envelope(&)
    html do
      body do
        yield
      end
    end
  end
end

example = Example.new
example.to_html # => "<html><body><h1>Hello</h1></body></html>"

Breaking changes

  • Requires require "blueprint/html" instead require "blueprint" to use Blueprint::HTML module