Sha256: be3b087975206af06a641f178c14aba2a46dfce270bbf1cfbbd5e9c9a57df91c

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 Bytes

Contents

module AngularSprinkles
  module Helpers
    module DirectiveHelper
      def directive(directive_name, options = {}, &block)
        if block_given?
          controller = Directive::Controller.new({
            name: "#{directive_name}Ctrl",
            object_wrapper: ObjectKeyWrapper,
            bind_json_wrapper: JavaScript::NoOp,
            call_json_wrapper: JavaScript::BindService
          })

          content = capture(controller, &block)
        end

        name = Directive::Name.new(directive_name)
        input = Directive::Input.new(options.except(:html))
        html = Directive::Html.new(options[:html])

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

        content_tag(*attributes.to_content_tag)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
angular_sprinkles-0.2.14 lib/angular_sprinkles/helpers/directive_helper.rb
angular_sprinkles-0.2.13 lib/angular_sprinkles/helpers/directive_helper.rb
angular_sprinkles-0.2.12 lib/angular_sprinkles/helpers/directive_helper.rb