Class: Glimmer::DSL::Web::ElementExpression
- Inherits:
-
Expression
- Object
- Expression
- Glimmer::DSL::Web::ElementExpression
- Includes:
- GeneralElementExpression
- Defined in:
- lib/glimmer/dsl/web/element_expression.rb
Constant Summary collapse
- REGEXP_ARG_TYPE_STRING =
/(String)*(Hash)?/
Instance Method Summary collapse
Methods included from GeneralElementExpression
Instance Method Details
#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/glimmer/dsl/web/element_expression.rb', line 14 def can_interpret?(parent, keyword, *args, &block) slot = keyword.to_s.to_sym Glimmer::Web::ElementProxy.keyword_supported?(keyword) && ( ( args.empty? && ( parent.nil? || !parent.respond_to?(:slot_elements) || !(parent.slot_elements.keys.include?(slot) || parent.slot_elements.keys.include?(slot.to_s)) ) ) || valid_element_args?(args) ) && ( keyword != 'title' || parent.nil? || parent.keyword == 'head' ) && ( # ensure SVG keywords only live under SVG element (unless it's the SVG element itself) !Glimmer::Web::ElementProxy.svg_keyword_supported?(keyword) || keyword == 'svg' || parent.find_ancestor(include_self: true) { |ancestor| ancestor.keyword == 'svg' } ) end |
#valid_element_args?(args) ⇒ Boolean
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/glimmer/dsl/web/element_expression.rb', line 40 def valid_element_args?(args) arg_types = args.map do |arg| if arg.is_a?(String) 'String' elsif arg.is_a?(Hash) 'Hash' else 'Unsupported' end end arg_type_string = arg_types.join arg_type_string.match(REGEXP_ARG_TYPE_STRING) end |