Class: Muwu::RenderHtmlPartial::DocumentHtml
- Inherits:
-
Object
- Object
- Muwu::RenderHtmlPartial::DocumentHtml
show all
- Includes:
- Muwu
- Defined in:
- lib/muwu/render_html_partial/render_document_html.rb
Constant Summary
Constants included
from Muwu
GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Muwu
debug, read
Constructor Details
Returns a new instance of DocumentHtml.
28
29
30
31
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 28
def initialize
@head_metadata = {}
@tasks = []
end
|
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def destination
@destination
end
|
#head_css_filename ⇒ Object
Returns the value of attribute head_css_filename.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_css_filename
@head_css_filename
end
|
#head_css_method ⇒ Object
Returns the value of attribute head_css_method.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_css_method
@head_css_method
end
|
Returns the value of attribute head_includes_metadata_tags.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_includes_metadata_tags
@head_includes_metadata_tags
end
|
#head_js_filename ⇒ Object
Returns the value of attribute head_js_filename.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_js_filename
@head_js_filename
end
|
#head_js_libraries ⇒ Object
Returns the value of attribute head_js_libraries.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_js_libraries
@head_js_libraries
end
|
#head_js_method ⇒ Object
Returns the value of attribute head_js_method.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_js_method
@head_js_method
end
|
Returns the value of attribute head_metadata.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def head_metadata
@head_metadata
end
|
#html_lang ⇒ Object
Returns the value of attribute html_lang.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def html_lang
@html_lang
end
|
#html_title ⇒ Object
Returns the value of attribute html_title.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def html_title
@html_title
end
|
#project ⇒ Object
Returns the value of attribute project.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def project
@project
end
|
#tasks ⇒ Object
Returns the value of attribute tasks.
12
13
14
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 12
def tasks
@tasks
end
|
Instance Method Details
#options ⇒ Object
51
52
53
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 51
def options
@project.options
end
|
#render ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 39
def render
@destination.output_stream do
render_tag_html_open
@destination.padding_vertical(1) do
render_head
render_body
end
write_tag_html_close
end
end
|
#render_body ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 56
def render_body
@destination.padding_vertical(1) do
write_tag_body_open
render_body_manifest_tasks
write_tag_body_close
end
end
|
#render_body_manifest_tasks ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 65
def render_body_manifest_tasks
@destination.padding_vertical(1) do
@tasks.each do |task|
task.render
end
end
end
|
#render_head ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 74
def render_head
@destination.padding_vertical(1) do
write_tag_head_open
@destination.margin_indent do
write_tag_title
render_head_meta_tags
render_head_css
render_head_js
end
write_tag_head_close
end
end
|
#render_head_css ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 88
def render_head_css
case @head_css_method
when :embed
render_head_css_embed
when :link
render_head_css_link
end
end
|
#render_head_css_embed ⇒ Object
98
99
100
101
102
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 98
def render_head_css_embed
write_tag_style_open
write_css_if_manifest_exists
write_tag_style_close
end
|
#render_head_css_link ⇒ Object
105
106
107
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 105
def render_head_css_link
write_tag_link_stylesheet
end
|
#render_head_js ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 110
def render_head_js
case @head_js_method
when :embed
render_head_js_embed
when :link
render_head_js_link
end
end
|
#render_head_js_embed ⇒ Object
120
121
122
123
124
125
126
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 120
def render_head_js_embed
write_tag_script_open
@head_js_libraries.each do |library|
write_js_library(library)
end
write_tag_script_close
end
|
#render_head_js_lib_navigation ⇒ Object
129
130
131
132
133
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 129
def render_head_js_lib_navigation
if @project.options.html_uses_javascript_navigation
write_js_lib_navigation
end
end
|
#render_head_js_link ⇒ Object
136
137
138
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 136
def render_head_js_link
write_tag_script_src
end
|
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 141
def render_head_meta_tags
write_tag_meta_charset_utf8
if @head_includes_metadata_tags
@head_metadata.each_pair do |key, value|
write_tag_meta(key, value)
end
end
write_tag_meta_generator
write_tag_meta_viewport
end
|
#render_tag_html_open ⇒ Object
153
154
155
156
157
158
159
160
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 153
def render_tag_html_open
write_tag_doctype
if @html_lang
write_tag_html_open_lang
else
write_tag_html_open
end
end
|
#write_css ⇒ Object
172
173
174
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 172
def write_css
@destination.write_inline SassC::Engine.new(File.read(@project.css_manifest_filename), syntax: :scss, load_paths: ['config/css']).render
end
|
#write_css_if_manifest_exists ⇒ Object
163
164
165
166
167
168
169
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 163
def write_css_if_manifest_exists
if @project.exceptions_include?(ProjectException::CssManifestFileNotFound)
else
write_css
end
end
|
177
178
179
180
181
182
183
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 177
def
@destination.write_line "/*"
@destination.write_line "#{ProjectException::CssManifestFileNotFound}"
@destination.write_line " - CSS manifest file could not be found."
@destination.write_line " - Expecting `#{project.css_manifest_filename}`"
@destination.write_line "*/"
end
|
#write_js_library(library) ⇒ Object
186
187
188
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 186
def write_js_library(library)
@destination.write_inline RenderHtmlPartial::JsLibrary.new.find(library)
end
|
#write_tag_body_close ⇒ Object
191
192
193
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 191
def write_tag_body_close
@destination.write_line tag_body_close
end
|
#write_tag_body_open ⇒ Object
196
197
198
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 196
def write_tag_body_open
@destination.write_line tag_body_open
end
|
#write_tag_doctype ⇒ Object
201
202
203
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 201
def write_tag_doctype
@destination.write_line tag_doctype
end
|
#write_tag_head_close ⇒ Object
206
207
208
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 206
def write_tag_head_close
@destination.write_line tag_head_close
end
|
#write_tag_head_open ⇒ Object
211
212
213
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 211
def write_tag_head_open
@destination.write_line tag_head_open
end
|
#write_tag_html_close ⇒ Object
216
217
218
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 216
def write_tag_html_close
@destination.write_line tag_html_close
end
|
#write_tag_html_open ⇒ Object
221
222
223
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 221
def write_tag_html_open
@destination.write_line tag_html_open
end
|
#write_tag_html_open_lang ⇒ Object
226
227
228
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 226
def write_tag_html_open_lang
@destination.write_line tag_html_open_lang
end
|
#write_tag_link_stylesheet ⇒ Object
231
232
233
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 231
def write_tag_link_stylesheet
@destination.write_line tag_link_stylesheet
end
|
236
237
238
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 236
def write_tag_meta(key, value)
@destination.write_line tag_meta(key, value)
end
|
241
242
243
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 241
def write_tag_meta_charset_utf8
@destination.write_line tag_meta_charset_utf8
end
|
246
247
248
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 246
def write_tag_meta_generator
@destination.write_line tag_meta_generator
end
|
256
257
258
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 256
def write_tag_meta_instance_date
@destination.write_line tag_meta_instance_date
end
|
251
252
253
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 251
def write_tag_meta_viewport
@destination.write_line tag_meta_viewport
end
|
#write_tag_script_close ⇒ Object
261
262
263
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 261
def write_tag_script_close
@destination.write_line tag_script_close
end
|
#write_tag_script_open ⇒ Object
266
267
268
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 266
def write_tag_script_open
@destination.write_line tag_script_open
end
|
#write_tag_script_src ⇒ Object
271
272
273
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 271
def write_tag_script_src
@destination.write_line tag_script_src
end
|
#write_tag_style_close ⇒ Object
276
277
278
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 276
def write_tag_style_close
@destination.write_line tag_style_close
end
|
#write_tag_style_open ⇒ Object
281
282
283
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 281
def write_tag_style_open
@destination.write_line tag_style_open
end
|
#write_tag_title ⇒ Object
286
287
288
|
# File 'lib/muwu/render_html_partial/render_document_html.rb', line 286
def write_tag_title
@destination.write_line tag_title
end
|