Sha256: 07f47390e078153fd37c269c17da67298b8751c6cbdb3d733e965d6755dbcd95

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# -*- coding: utf-8 -*-

require 'turnip_formatter/template'
require 'sass'
require 'uglifier'

module TurnipFormatter
  class Template
    class << self
      def add_js(js_string)
        js_list << js_string
      end

      def add_js_file(file)
        js_list << Uglifier.compile(File.read(file))
      end

      def add_scss(scss_string)
        css_list << Sass::Engine.new(scss_string, scss_option).render
      end

      def add_scss_file(path)
        css_list << Sass::Engine.for_file(path, scss_option).render
      end

      def js_render
        js_list.join("\n")
      end

      def css_render
        css_list.join("\n")
      end

      def js_list
        @js_list ||= []
      end

      def css_list
        @css_list ||= []
      end

      def scss_option
        { syntax: :scss, style: :compressed }
      end
    end
  end
end

(File.dirname(__FILE__) + '/template').tap do |dirname|
  TurnipFormatter::Template.add_scss_file(dirname + '/turnip_formatter.scss')
  TurnipFormatter::Template.add_js_file(dirname + '/turnip_formatter.js')
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
turnip_formatter-0.2.5 lib/turnip_formatter/template.rb
turnip_formatter-0.2.4 lib/turnip_formatter/template.rb
turnip_formatter-0.2.3 lib/turnip_formatter/template.rb
turnip_formatter-0.2.2 lib/turnip_formatter/template.rb