Class: ExternalRenderer
- Inherits:
-
Erector::Widget
- Object
- Erector::AbstractWidget
- Erector::XMLWidget
- Erector::HTMLWidget
- Erector::Widget
- ExternalRenderer
- Defined in:
- lib/erector/widgets/external_renderer.rb
Instance Method Summary collapse
- #content ⇒ Object
- #included_scripts ⇒ Object
- #included_stylesheets ⇒ Object
- #inline_scripts ⇒ Object
- #inline_styles ⇒ Object
- #rendered_externals(type) ⇒ Object
Methods inherited from Erector::Widget
Methods included from Erector::Sass
Methods included from Erector::JQuery
#jquery, #jquery_load, #jquery_ready
Methods included from Erector::Convenience
#css, #dom_id, #javascript, #join, #to_pretty, #to_text, #url
Methods included from Erector::Externals
included, #render_externals, #render_with_externals
Methods included from Erector::Caching
#cache, included, #should_cache?
Methods included from Erector::Needs
Methods inherited from Erector::HTMLWidget
Methods inherited from Erector::XMLWidget
#comment, full_tags, #instruct, #newliney?, self_closing_tags, tag, tag_named
Methods inherited from Erector::AbstractWidget
#call_block, #capture_content, #emit, hyphenize_underscores, hyphenize_underscores=, #initialize, inline, prettyprint_default, #prettyprint_default, prettyprint_default=, #to_a, #to_s, #widget
Methods included from Erector::AfterInitialize
Methods included from Erector::Text
#character, #h, #nbsp, #raw, #text, #text!
Methods included from Erector::Attributes
#format_attributes, #format_sorted, #sort_attributes
Methods included from Erector::Element
#_element, #_empty_element, #element, #empty_element
Instance Method Details
#content ⇒ Object
5 6 7 8 9 10 |
# File 'lib/erector/widgets/external_renderer.rb', line 5 def content included_stylesheets if @included_stylesheets inline_styles if @inline_styles included_scripts if @included_scripts inline_scripts if @inline_scripts end |
#included_scripts ⇒ Object
18 19 20 21 22 |
# File 'lib/erector/widgets/external_renderer.rb', line 18 def included_scripts rendered_externals(:js).each do |external| script({:type => "text/javascript", :src => external.text}.merge(external.)) end end |
#included_stylesheets ⇒ Object
24 25 26 27 28 |
# File 'lib/erector/widgets/external_renderer.rb', line 24 def included_stylesheets rendered_externals(:css).each do |external| link({:rel => "stylesheet", :href => external.text, :type => "text/css", :media => "all"}.merge(external.)) end end |
#inline_scripts ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/erector/widgets/external_renderer.rb', line 46 def inline_scripts rendered_externals(:script).each do |external| javascript external. do rawtext external.text end end # todo: allow :load or :ready per external script rendered_externals(:jquery).each do |external| jquery :load, external.text, external. end end |
#inline_styles ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/erector/widgets/external_renderer.rb', line 30 def inline_styles rendered_externals(:style).each do |external| style({:type => "text/css", 'xml:space' => 'preserve'}.merge(external.)) do rawtext external.text end end if Object.const_defined?(:Sass) rendered_externals(:scss).each do |external| style({:type => "text/css", 'xml:space' => 'preserve'}.merge(external.)) do rawtext Sass.compile(external.text) end end end end |
#rendered_externals(type) ⇒ Object
12 13 14 15 16 |
# File 'lib/erector/widgets/external_renderer.rb', line 12 def rendered_externals(type) @classes.map do |klass| klass.dependencies(type) end.flatten.uniq end |