m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib/templated.rb
blob: 548352c1120c6b50863bcbf629e2bd77a72a6714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def write_templated_file content_filename, title
  content = File.read(src content_filename)
  write_templated content, content_filename, title
end

def write_erb erb_filename
  content = ERB.new(File.read(src erb_filename)).result
  cut_filename = erb_filename.sub /\.erb$/, ''
  File.write build(cut_filename), content
end

def write_templated_erb erb_filename, title = nil
  content = ERB.new(File.read(src erb_filename), trim_mode: '-').result
  cut_filename = erb_filename.sub /\.erb$/, ''
  write_templated content, cut_filename, title
end

def write_templated content, filename, title = nil
  File.write build(filename), page_template.result(binding)
end