Class: EZML::AttributeCompiler
Defined Under Namespace
Classes: AttributeValue
Class Method Summary collapse
Instance Method Summary collapse
- #compile(attributes, object_ref, dynamic_attributes) ⇒ Object
-
#initialize(options) ⇒ AttributeCompiler
constructor
A new instance of AttributeCompiler.
Constructor Details
#initialize(options) ⇒ AttributeCompiler
Returns a new instance of AttributeCompiler.
22 23 24 25 26 27 |
# File 'lib/ezml/attribute_compiler.rb', line 22 def initialize() @is_html = [:html4, :html5].include?([:format]) @attr_wrapper = [:attr_wrapper] @escape_attrs = [:escape_attrs] @hyphenate_data_attrs = [:hyphenate_data_attrs] end |
Class Method Details
.runtime_build(attributes, object_ref, dynamic_attributes) ⇒ Object
18 19 20 |
# File 'lib/ezml/attribute_compiler.rb', line 18 def self.runtime_build(attributes, object_ref, dynamic_attributes) "_ezmlout.attributes(#{EZML::Util.inspect_obj(attributes)}, #{object_ref},#{dynamic_attributes.to_literal})" end |
Instance Method Details
#compile(attributes, object_ref, dynamic_attributes) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ezml/attribute_compiler.rb', line 29 def compile(attributes, object_ref, dynamic_attributes) if object_ref != :nil || !AttributeParser.available? return [:dynamic, AttributeCompiler.runtime_build(attributes, object_ref, dynamic_attributes)] end parsed_hashes = [dynamic_attributes.new, dynamic_attributes.old].compact.map do |attribute_hash| unless (hash = AttributeParser.parse(attribute_hash)) return [:dynamic, AttributeCompiler.runtime_build(attributes, object_ref, dynamic_attributes)] end hash end attribute_values = build_attribute_values(attributes, parsed_hashes) AttributeBuilder.verify_attribute_names!(attribute_values.map(&:key)) [:multi, *group_values_for_sort(attribute_values).map { |value_group| compile_attribute_values(value_group) }] end |