Sha256: 66e5c3af94011e24248d5e01a06ac14ed6cfc98b742f5f4a33200d5b2afa58ae

Contents?: true

Size: 601 Bytes

Versions: 3

Compression:

Stored size: 601 Bytes

Contents

require "sinatra/base"
require "scss_beautifier"

class ScssBeautifierApp < Sinatra::Base

  get "/" do
    redirect '/index.html'
  end

  post "/beautify" do
    engine = Sass::Engine.new(request.body.read.to_s, cache: false, syntax: :scss)

    begin
      tree = engine.to_tree
    rescue Sass::SyntaxError => e
      return e.message
    end

    config = SCSSBeautifier::Config.new(SCSSBeautifier::CLI::DEFAULT)

    config.formatters.each do |formatter|
      formatter.send(:visit, tree)
    end

    output = SCSSBeautifier::Convert.visit(tree, {indent: config.tab_style}, :scss)

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scss_beautifier-0.1.18 web/app.rb
scss_beautifier-0.1.17 web/app.rb
scss_beautifier-0.1.16 web/app.rb