Module: RTram::Converter

Defined in:
lib/rtram/converter.rb

Class Method Summary collapse

Class Method Details

.convert(f, working_directory) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/rtram/converter.rb', line 9

def convert(f, working_directory)
  extname = File.extname(f)
  if extname == '.slim'
    slim2html(f, working_directory)
  elsif extname == '.sass' || extname == '.scss'
    sass2css(f, working_directory)
  end
end

.sass2css(f, working_directory) ⇒ Object


27
28
29
30
31
32
33
34
# File 'lib/rtram/converter.rb', line 27

def sass2css(f, working_directory)
  basename = File.basename(f, ".*")
  css_name = basename + '.css'
  sass = Sass.compile(f)
  File.open("#{working_directory}/output/css/#{css_name}", 'w') do |f|
    f.write(sass.css)
  end
end

.slim2html(f, working_directory) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/rtram/converter.rb', line 18

def slim2html(f, working_directory)
  basename = File.basename(f, ".*")
  html_name = basename + '.html'
  html = Slim::Template.new(f, { pretty: true }).render
  File.open("#{working_directory}/output/#{html_name}", 'w') do |f|
    f.write(html)
  end
end