Class: Gryphon::Processors::MustacheProcessor
- Inherits:
-
Object
- Object
- Gryphon::Processors::MustacheProcessor
- Includes:
- FileWriter
- Defined in:
- lib/gryphon/processors/mustache_processor.rb
Overview
Renders a Mustache template into a html file
Instance Method Summary collapse
- #dest_name(src) ⇒ Pathname
- #file_modified?(src, dest) ⇒ Boolean
-
#initialize(renderer, layout_file) ⇒ MustacheProcessor
constructor
A new instance of MustacheProcessor.
- #process(src, dest) ⇒ Object
Methods included from FileWriter
Constructor Details
#initialize(renderer, layout_file) ⇒ MustacheProcessor
Returns a new instance of MustacheProcessor.
13 14 15 16 |
# File 'lib/gryphon/processors/mustache_processor.rb', line 13 def initialize(renderer, layout_file) @renderer = renderer @layout_file = layout_file end |
Instance Method Details
#dest_name(src) ⇒ Pathname
28 29 30 31 32 33 34 35 36 |
# File 'lib/gryphon/processors/mustache_processor.rb', line 28 def dest_name(src) dir = src.dirname path = dir.sub(CONTENT_DIR, BUILD_DIR) basename = src.basename(TEMPLATE_EXT) path = path.join(basename) if basename.to_s != 'index' path.join('index.html') end |
#file_modified?(src, dest) ⇒ Boolean
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gryphon/processors/mustache_processor.rb', line 41 def file_modified?(src, dest) return true unless dest.exist? mod_time = dest.mtime return true if src.mtime > mod_time return false unless @layout_file.exist? @layout_file.mtime > mod_time end |
#process(src, dest) ⇒ Object
21 22 23 24 |
# File 'lib/gryphon/processors/mustache_processor.rb', line 21 def process(src, dest) content = build_output(src) write_file(dest, content) end |