lib/lotus/helpers/html_helper.rb in lotus-helpers-0.2.5 vs lib/lotus/helpers/html_helper.rb in lotus-helpers-0.2.6
- old
+ new
@@ -63,12 +63,21 @@
# # =>
# #<div id="yay">
# # hello
# #</div>
#
+ # # 8
+ # html do
+ # li 'Hello'
+ # li 'Lotus'
+ # end
+ # # =>
+ # #<li>Hello</li>
+ # #<li>Lotus</li>
#
#
+ #
# @example Complex markup
# #
# # NOTICE THE LACK OF CONCATENATION BETWEEN div AND input BLOCKS <3
# #
#
@@ -176,17 +185,23 @@
# # </div>
module HtmlHelper
private
# Instantiate an HTML builder
#
+ # @param blk [Proc,Lotus::Helpers::HtmlHelper::HtmlBuilder,NilClass] the optional content block
+ #
# @return [Lotus::Helpers::HtmlHelper::HtmlBuilder] the HTML builder
#
# @since 0.1.0
#
# @see Lotus::Helpers::HtmlHelper
# @see Lotus::Helpers::HtmlHelper::HtmlBuilder
- def html
- HtmlBuilder.new
+ def html(&blk)
+ if block_given?
+ HtmlBuilder.new.fragment(&blk)
+ else
+ HtmlBuilder.new
+ end
end
end
end
end