Externals are a mechanism by which a widget can declare page-level resources upon which it depends. They are not emitted during the widget's normal emiting process. Rather, the Erector::Widget::Page keeps track of all the widgets it emits, then goes back and inserts the proper tags for all the externals inside its HEAD element.
# File lib/erector/externals.rb, line 9 def self.included(base) base.extend ClassMethods end
# File lib/erector/externals.rb, line 96 def render_externals(options_to_external_emiter = {}) output_for_externals = Erector::Output.new nested_widgets = output.widgets externalizer = ExternalRenderer.new({:classes => nested_widgets}.merge(options_to_external_emiter)) externalizer._emit(:output => output_for_externals) output_for_externals.to_a end
# File lib/erector/externals.rb, line 86 def render_with_externals(options_to_external_emiter = {}) output = Erector::Output.new self.to_a(:output => output) # emit all the externals onto this new output buffer nested_widgets = output.widgets.to_a options_to_external_emiter = {:classes => nested_widgets}.merge(options_to_external_emiter) emiter = ExternalRenderer.new(options_to_external_emiter) externals = emiter.to_a(:output => output) output.to_a end