Class: ExternalRenderer
Instance Method Summary
collapse
#sass
included, #initialize
#jquery, #jquery_load, #jquery_ready
#css, #dom_id, #join, #to_pretty, #to_text, #url
included, #render_externals, #render_with_externals
included, #initialize
#character, #close_tag, #comment, #element, #element!, #empty_element, #h, included, #instruct, #javascript, #nbsp, #open_tag, #raw, #text, #text!
#call_block, #capture, #initialize, inline, prettyprint_default, #prettyprint_default, prettyprint_default=, #to_a, #to_html, #to_s, #widget
Instance Method Details
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.options))
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.options))
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.options do
rawtext external.text
end
end
rendered_externals(:jquery).each do |external|
jquery :load, external.text, external.options
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.options)) 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
|