Class: Thredded::MarkdownKatex::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/thredded/markdown_katex/install_generator.rb

Overview

Installs Thredded Katex plugin

Instance Method Summary collapse

Instance Method Details

#installObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/thredded/markdown_katex/install_generator.rb', line 10

def install
  %w[application.scss _deps.scss].each do |scss_file|
    scss_path = File.join('app', 'assets', 'stylesheets', scss_file)
    next unless File.exist? scss_path

    append_to_file scss_path, "\n@import \"_katex\";\n"
  end
  sass_path = 'app/assets/stylesheets/application.sass'
  append_to_file sass_path, "\n@import \"_katex\"\n" if File.exist? sass_path
  css_path = 'app/assets/stylesheets/application.css'
  append_to_file css_path, "\n//= require katex\n" if File.exist? css_path
end