Class: YMDP::Compiler::Template::View
- Includes:
- ActionView::Helpers::TagHelper, ApplicationHelper, ApplicationView, AssetTagHelper, FormTagHelper, LinkTagHelper
- Defined in:
- lib/ymdp/compiler/template.rb
Direct Known Subclasses
Constant Summary
Constants included from ActionView::Helpers::TagHelper
ActionView::Helpers::TagHelper::BOOLEAN_ATTRIBUTES
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Attributes inherited from Base
#assets_directory, #domain, #file, #hash, #host, #message, #server
Instance Method Summary collapse
-
#base_filename(filename) ⇒ Object
Filename without its extension:.
-
#convert_filename(filename) ⇒ Object
Filename without its extension:.
- #process_coffee(template, filename = nil) ⇒ Object
-
#process_erb(template) ⇒ Object
Process this template with ERB.
-
#process_haml(template, filename = nil) ⇒ Object
Process this template with Haml.
- #process_scss(template, filename = nil) ⇒ Object
- #validator ⇒ Object
-
#write_template(result) ⇒ Object
Write this template with the application layout applied.
Methods included from LinkTagHelper
#link_to, #link_to_function, #link_to_unless_current
Methods included from FormTagHelper
#label, #password_field, #text_field
Methods included from AssetTagHelper
Methods included from ApplicationView
#combo, #english_languages, #include_firebug_lite, #javascript_include, #render, #supported_languages, #translations
Methods included from ActionView::Helpers::TagHelper
#cdata_section, #content_tag, #escape_once, #tag
Methods inherited from Base
#build, #destination_path, #initialize, #partial?, #processed_template, #server_path, #servers_path, #set_content_variables, #verbose, #verbose?, #write_template_with_layout, #write_template_without_layout
Methods inherited from Base
#base_path, base_path, #configuration, configuration, configure, #content_variables, display_path, #display_path, #paths, #servers
Constructor Details
This class inherits a constructor from YMDP::Compiler::Template::Base
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
242 243 244 |
# File 'lib/ymdp/compiler/template.rb', line 242 def output_buffer @output_buffer end |
Instance Method Details
#base_filename(filename) ⇒ Object
Filename without its extension:
-
“authorize.html.haml” becomes “authorize”
248 249 250 |
# File 'lib/ymdp/compiler/template.rb', line 248 def base_filename(filename) filename.gsub(/(\.html|\.erb|\.haml)/, "") end |
#convert_filename(filename) ⇒ Object
Filename without its extension:
-
“authorize.html.haml” becomes “authorize”
256 257 258 |
# File 'lib/ymdp/compiler/template.rb', line 256 def convert_filename(filename) base_filename(filename) end |
#process_coffee(template, filename = nil) ⇒ Object
282 283 284 |
# File 'lib/ymdp/compiler/template.rb', line 282 def process_coffee(template, filename=nil) ::CoffeeScript.compile(process_erb(template)) end |
#process_erb(template) ⇒ Object
Process this template with ERB.
262 263 264 265 |
# File 'lib/ymdp/compiler/template.rb', line 262 def process_erb(template) # puts "View process_erb" ERB.new(template, 0, "%<>").result(binding) end |
#process_haml(template, filename = nil) ⇒ Object
Process this template with Haml.
269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/ymdp/compiler/template.rb', line 269 def process_haml(template, filename=nil) # puts "View process_haml" = { :doctype => :html4 } if filename [:filename] = filename end ::Haml::Engine.new(template, ).render(self) do yield end end |
#process_scss(template, filename = nil) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/ymdp/compiler/template.rb', line 286 def process_scss(template, filename=nil) = { :syntax => :scss } if filename [:filename] = filename end ::Sass::Engine.new(template, ).render do yield end end |
#validator ⇒ Object
312 313 314 |
# File 'lib/ymdp/compiler/template.rb', line 312 def validator @validator ||= Epic::Validator::HTML.new end |
#write_template(result) ⇒ Object
Write this template with the application layout applied.
Validate the resulting HTML file if that option is turned on.
302 303 304 305 306 307 308 309 310 |
# File 'lib/ymdp/compiler/template.rb', line 302 def write_template(result) result = super(result) if configuration.validate["html"]["build"] && !validator.validate(destination_path) raise "HTML Validation Errors" end result end |