Module: Nom::XML::NokogiriExtension
- Defined in:
- lib/nom/xml/nokogiri_extension.rb
Instance Method Summary collapse
-
#define_template(name, &block) ⇒ Object
Define a new node template with the Nom::XML::TemplateRegistry.
- #nom! ⇒ Object
- #set_terminology(options = {}, &block) ⇒ Object
- #template_registry ⇒ Object
- #terminology ⇒ Object
- #terminology_namespaces ⇒ Object
Instance Method Details
#define_template(name, &block) ⇒ Object
Define a new node template with the Nom::XML::TemplateRegistry.
-
name
is a Symbol indicating the name of the new template. -
The
block
does the work of creating the new node, and will receive a Nokogiri::XML::Builder and any other args passed to one of the node instantiation methods.
44 45 46 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 44 def define_template name, &block self.template_registry.define name, &block end |
#nom! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 6 def nom! unless decorators(Nokogiri::XML::Node).include? Nom::XML::Decorators::Terminology decorators(Nokogiri::XML::Node) << Nom::XML::Decorators::Terminology end unless decorators(Nokogiri::XML::NodeSet).include? Nom::XML::Decorators::NodeSet decorators(Nokogiri::XML::NodeSet) << Nom::XML::Decorators::NodeSet end unless decorators(Nokogiri::XML::Document).include? Nom::XML::Decorators::TemplateRegistry decorators(Nokogiri::XML::Document) << Nom::XML::Decorators::TemplateRegistry end decorate! self end |
#set_terminology(options = {}, &block) ⇒ Object
23 24 25 26 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 23 def set_terminology = {}, &block @terminology_namespaces = [:namespaces] @terminology = Nom::XML::Terminology.new(self, , &block) end |
#template_registry ⇒ Object
36 37 38 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 36 def template_registry @template_registry ||= Nom::XML::TemplateRegistry.new end |
#terminology ⇒ Object
32 33 34 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 32 def terminology @terminology ||= Nom::XML::Terminology.new self end |
#terminology_namespaces ⇒ Object
28 29 30 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 28 def terminology_namespaces @terminology_namespaces ||= {} end |