Class: ExternalRenderer
- Inherits:
-
Erector::Widget
- Object
- Erector::AbstractWidget
- 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 included from Erector::Sass
Methods included from Erector::AfterInitialize
Methods included from Erector::JQuery
#jquery, #jquery_load, #jquery_ready
Methods included from Erector::Convenience
#css, #dom_id, #join, #to_pretty, #to_text, #url
Methods included from Erector::Externals
included, #render_externals, #render_with_externals
Methods included from Erector::Caching
#_render, #_render_via, #cache, included, #should_cache?
Methods included from Erector::Needs
Methods included from Erector::HTML
#character, #close_tag, #comment, #element, #element!, #empty_element, #h, included, #instruct, #javascript, #nbsp, #open_tag, #raw, #text, #text!
Methods inherited from Erector::AbstractWidget
#call_block, #capture, #initialize, inline, prettyprint_default, #prettyprint_default, prettyprint_default=, #to_a, #to_html, #to_s, #widget
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
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/erector/widgets/external_renderer.rb', line 38 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 |
# 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 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 |