Sha256: 8aaa9711bfe536a54dd4a897f9f59d2fc196596a13d7b63f2691132b157cec92

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module KepplerFrontend
  module Views
  # Assets
    class ThemeViews
      def initialize; end

      def select_theme(config)
        erb?(config) ? paste_erb(config) : paste_haml(config)
      end

      private

      def rocket_url
        'rockets/keppler_frontend'
      end

      def views_folder
        "#{rocket_url}/app/views/keppler_frontend/app/"
      end

      def erb?(config)
        config[:view_format].eql?('erb')
      end

      def paste_erb(config)
        view = "#{views_folder}/#{config[:view]}"
        theme = "#{rocket_url}/app#{config[:theme]}"
        theme = File.readlines(theme)
        File.write(view, theme.join)
      end

      def paste_haml(config)
        view = "#{views_folder}/#{config[:view]}"
        theme = "#{rocket_url}/app#{config[:theme]}"
        theme = File.readlines(theme)
        File.write(view, theme.join)
        convert_to_haml(view)
      end

      def convert_to_haml(view)
        output = "#{views_folder}/output.haml}"
        system("html2haml --erb #{view} #{output}")
        theme = File.readlines(output)
        File.write(view, theme.join)
        File.delete(output) if File.exist?(output)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/theme_views.rb
keppler-2.1.21 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/theme_views.rb
keppler-2.1.20 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/theme_views.rb
keppler-2.1.19 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/theme_views.rb