Sha256: 2773ed54515bd21cba66fa0b6c0fc0b4b94f4dfbfe8a5e6e2e9740cfe15264c1

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

module AngularSprinkles
  module Helpers
    module ElementHelper
      def _element(opts = {}, &block)
        options = opts.dup.symbolize_keys

        scope_name = options.delete(:scope_name)
        html_options = options.delete(:html) || {}
        input_options = options # use remaining options

        if block_given?
          scope = Element::Scope.new({
            base: scope_name,
            object_wrapper: ObjectKeyWrapper,
            bind_json_wrapper: JavaScript::NoOp,
            call_json_wrapper: JavaScript::BindService
          })

          content = capture(scope, &block)
        end

        input = Element::Input.new(input_options)
        html = Element::Html.new(html_options)

        attributes = Element::Attributes.new([input, html], tag: html.tag, content: content)

        content_tag(*attributes.to_content_tag)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
angular_sprinkles-0.3.1 lib/angular_sprinkles/helpers/element_helper.rb
angular_sprinkles-0.3.0 lib/angular_sprinkles/helpers/element_helper.rb