Class: Charsi::Template
- Inherits:
-
Object
- Object
- Charsi::Template
- Defined in:
- lib/charsi/template.rb
Overview
Itterates over all views and builds them into the output directory.
Each view is created with a layout. The default layout is ‘default.erb`.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(app, config) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(app, config) ⇒ Template
Returns a new instance of Template.
6 7 8 9 |
# File 'lib/charsi/template.rb', line 6 def initialize(app, config) @app = app @config = config end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/charsi/template.rb', line 11 def build views_path = @config.path(:views_dir, '*.erb') Dir.glob(views_path).each do |view| next if File.basename(view).start_with?('_') output_file = determine_output_filename(view) output_path = @config.path(:output_dir, output_file) processed_view = parse_erb_with_layout(view) Charsi::FileManagement.write(output_path, processed_view) end end |