lib/hanami/helpers/html_helper/html_builder.rb in hanami-helpers-1.0.0.beta1 vs lib/hanami/helpers/html_helper/html_builder.rb in hanami-helpers-1.0.0.beta2

- old
+ new

@@ -1,6 +1,6 @@ -require 'hanami/utils' # RUBY_VERSION >= '2.2' +require 'hanami/utils' require 'hanami/utils/class_attribute' require 'hanami/utils/escape' require 'hanami/helpers/html_helper/empty_html_node' require 'hanami/helpers/html_helper/html_node' require 'hanami/helpers/html_helper/html_fragment' @@ -40,10 +40,11 @@ colgroup data datalist del details + dialog dfn div dl dt dd @@ -59,18 +60,18 @@ h4 h5 h6 head header + hgroup i iframe ins kbd label legend li - link main map mark math menu @@ -86,16 +87,18 @@ pre progress q rp rt + rtc ruby s samp script section select + slot small span strong style sub @@ -113,10 +116,11 @@ time title tr u ul + var video ).freeze # HTML5 empty tags # @@ -181,10 +185,11 @@ # @api private def initialize @nodes = [] end + # @api private def options end # Define a custom tag # @@ -292,19 +297,22 @@ # @see Hanami::Helpers::HtmlHelper # @see Hanami::Helpers::HtmlHelper::TextNode # # @example # - # html.label do - # text "Option 1" - # radio_button :option, 1 - # end + # <%= + # html.label do + # text "Option 1" + # radio_button :option, 1 + # end + # %> # - # # <label> - # # Option 1 - # # <input type="radio" name="option" value="1" /> - # # </label> + # <!-- output --> + # <label> + # Option 1 + # <input type="radio" name="option" value="1" /> + # </label> def text(content) @nodes << TextNode.new(content) self end @@ -344,19 +352,23 @@ # @api private def nested? @nodes.any? end - # Resolve the context for nested contents - # - # @since 0.1.0 - # @api private - if RUBY_VERSION >= '2.2' && !Utils.jruby? + if !Utils.jruby? + # Resolve the context for nested contents + # + # @since 0.1.0 + # @api private def resolve(&blk) @context = blk.binding.receiver instance_exec(&blk) end else + # Resolve the context for nested contents + # + # @since 0.1.0 + # @api private def resolve(&blk) @context = eval 'self', blk.binding instance_exec(&blk) end end