-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add return type to builder methods (#41)
- Loading branch information
Showing
1 changed file
with
8 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
module Blueprint::HTML | ||
# EXPERIMENTAL | ||
def self.build(&) | ||
Builder.build do |builder| | ||
with builder yield | ||
end | ||
def self.build(&) : String | ||
Builder.build { |builder| with builder yield } | ||
end | ||
|
||
private struct Builder | ||
include Blueprint::HTML | ||
|
||
def self.build(&) | ||
def self.build(&) : String | ||
builder = new | ||
builder.build do | ||
yield builder | ||
end | ||
builder.build { yield builder } | ||
end | ||
|
||
private def blueprint(&) | ||
yield | ||
def build(&) : String | ||
to_html { with self yield } | ||
end | ||
|
||
protected def build(&) | ||
to_html { with self yield } | ||
private def blueprint(&) : Nil | ||
yield | ||
end | ||
end | ||
end |