Skip to content

v0.2.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@stephannv stephannv released this 07 Apr 13:02
· 79 commits to main since this 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

Full Changelog: v0.1.0...v0.2.0