Class: Textigniter::Build::RenderFiles
- Inherits:
-
Object
- Object
- Textigniter::Build::RenderFiles
- Defined in:
- lib/textigniter/build/render_files.rb
Overview
Instance Method Summary collapse
-
#render(items, format) ⇒ Object
Renders static content to file.
Instance Method Details
#render(items, format) ⇒ Object
Renders static content to file
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/textigniter/build/render_files.rb', line 10 def render(items, format) # Render each item items.each do |item| # Recursively create directory if it doesn't exist FileUtils.mkpath item['directory'] # Switch based on format and build a filename case format when 'content' filename = item['directory'] + '/index.html' when 'styles' filename = item['directory'] + '/' + item['filename'] + '.css' when 'scripts' filename = item['directory'] + '/' + item['filename'] + '.js' end # Write the output to file File.open(filename, 'w') do |file| file.write item['output'] end end end |