Method: BooticCli::Themes::FSTheme#add_template

Defined in:
lib/bootic_cli/themes/fs_theme.rb

#add_template(file_name, body) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bootic_cli/themes/fs_theme.rb', line 107

def add_template(file_name, body)
  setup
  path = File.join(dir, file_name)

  # remove DOS line endings for new templates
  # or for existing ones that don't have any.
  if !File.exist?(path) or !has_dos_line_endings?(path)
    body = body.gsub(/\r\n?/, "\n")
  end

  File.open(path, 'w') do |io|
    io.write(body)
  end

  @templates = nil
end