Sha256: 49999bf7d8614adb623f3f97b8c384ae8b6eaf346ae0e4108ca96362668b48eb
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
module Quarto module TransformationHelper # Tranforms the children of +element+ using # an instance of +transformer_class+ and returns # a string representation of the result. # # +transformer_class+ must be a subclass of # Quarto::Transformer or <tt>nil</tt>. If it's # <tt>nil</tt> (which is the default), the default # subclass will be used. The default subclass is set # in <tt>generate.rb</tt> as follows: # # config(:default_transformer_class, YourSubclass) # # If you do not specify a default class, # <tt>HtmlTransformer</tt> will be used. def transform_xml(element, transformer_class = Quarto::HtmlTransformer, raise_on_unrecognized_element = true) raise ArgumentError, "Expected REXML::Element but got #{element.inspect}" unless element.is_a?(REXML::Element) class_error = "Expected subclass of Tranformer but got #{transformer_class.inspect}" raise ArgumentError, class_error unless transformer_class.is_a?(Class) klass = transformer_class while klass != Quarto::Transformer and klass != Object klass = klass.superclass end raise ArgumentError, class_error unless Quarto::Transformer == klass transformer_class.new.transform(element, raise_on_unrecognized_element) end end end
Version data entries
5 entries across 5 versions & 1 rubygems