-
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.
- Loading branch information
Showing
8 changed files
with
46 additions
and
51 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Blueprint::HTML::BufferRenderer | ||
extend self | ||
|
||
def render(content : String, to buffer : String::Builder) | ||
::HTML.escape(content, buffer) | ||
end | ||
|
||
def render(content : Proc, to buffer : String::Builder) | ||
BlockRenderer.render(content, to: buffer) | ||
end | ||
|
||
def render(content : SafeObject, to buffer : String::Builder) | ||
content.to_s(buffer) | ||
end | ||
|
||
def render(content : Nil, to buffer : String::Builder) | ||
end | ||
|
||
def render(content, to buffer : String::Builder) | ||
::HTML.escape(content.to_s, buffer) | ||
end | ||
|
||
def render(to buffer : String::Builder, &) : Nil | ||
buffer_size_before_block_evaluation = buffer.bytesize | ||
content = yield | ||
return if buffer_size_before_block_evaluation != buffer.bytesize # return if something was written to buffer | ||
|
||
render(content, to: buffer) | ||
end | ||
|
||
def render(block : Proc, to buffer : String::Builder) : Nil | ||
buffer_size_before_block_evaluation = buffer.bytesize | ||
content = block.call | ||
return if buffer_size_before_block_evaluation != buffer.bytesize # return if something was written to buffer | ||
|
||
render(content, to: buffer) | ||
end | ||
end |
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
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
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
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