Sha256: 6273943a81523e10f9daa7b76d701f662d7602d03c5aa81c4db7a62609336f8d

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

module Kitabu
  class Exporter
    class CSS < Base
      attr_reader :root_dir

      def export
        files = Dir[root_dir.join("templates/styles/*.{scss,sass}").to_s]

        options = {
          style: :expanded,
          line_numbers: true,
          load_paths: [root_dir.join("templates/styles")]
        }

        files.each do |file|
          _, file_name, syntax = *File.basename(file).match(/(.*?)\.(.*?)$/)
          engine = Sass::Engine.new(File.read(file), options.merge(syntax: syntax.to_sym))
          target = root_dir.join("output/styles", "#{file_name}.css")
          FileUtils.mkdir_p(File.dirname(target))
          File.open(target, "w") {|io| io << engine.render }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kitabu-2.1.0 lib/kitabu/exporter/css.rb
kitabu-2.0.4 lib/kitabu/exporter/css.rb