Sha256: fd5e30d2f7ca1816c4b6ac980be0ec83e402429293e42db9091bf5a8010ef53d
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
require File.dirname(__FILE__) + "/../../command_handler" require File.dirname(__FILE__) + "/../node" module Glimmer module XML module CommandHandlers class HtmlCommandHandler include CommandHandler def can_handle?(parent, command_symbol, *args, &block) (parent == nil or parent.is_a?(Node)) and (args.size == 0 or ((args.size == 1) and ((args[0].is_a?(Hash)) or (args[0].is_a?(Hash))))) end def do_handle(parent, command_symbol, *args, &block) attributes = Hash.new attributes = args[0] if (args.size == 1) append_id_and_class_attributes(command_symbol.to_s, attributes) tag_name = parse_tag_name(command_symbol.to_s) Node.new(parent, tag_name, attributes, &block) end def parse_tag_name(command) match_data = command.match("_") if (match_data.to_a.size > 0) command.match("_").pre_match else command end end def append_id_and_class_attributes(command, attributes) class_only_match = command.match("__.+").to_s if class_only_match.length > 0 class_value = class_only_match[2, class_only_match.length] else match_data = command.match("_[^_]+") return unless match_data match = match_data.to_s id_value = match[1, match.length] if match.length > 0 attributes[:id] = id_value if id_value match2 = match_data.post_match.match("_[^_]+").to_s if match_data.post_match class_value = match2[1, match2.length] if match2.length > 0 end attributes[:class] = class_value if class_value end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems