1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Delete sass

This commit is contained in:
Eloy Pérez 2022-03-11 20:49:46 +01:00
parent 2b5d1b4509
commit ccb3273f6f
15 changed files with 6 additions and 242 deletions

1
.gitignore vendored
View file

@ -3,7 +3,6 @@
.DS_STORE
*.swp
*.rbc
*.sass-cache
/pkg
/Gemfile.lock
/coverage

View file

@ -45,7 +45,6 @@ gem 'rabl'
gem 'builder'
gem 'erubi'
gem 'haml', '~> 5'
gem 'sass'
gem 'celluloid', '~> 0.16.0'
gem 'commonmarker', '~> 0.20.0', platforms: [ :ruby ]
gem 'pandoc-ruby', '~> 2.0.2'

View file

@ -685,7 +685,7 @@ module Sinatra
# Possible options are:
# :content_type The content type to use, same arguments as content_type.
# :layout If set to something falsy, no layout is rendered, otherwise
# the specified layout is used (Ignored for `sass`)
# the specified layout is used
# :layout_engine Engine to use for rendering the layout.
# :locals A hash with local variables that should be available
# in the template
@ -711,16 +711,6 @@ module Sinatra
render(:haml, template, options, locals, &block)
end
def sass(template, options = {}, locals = {})
options.merge! :layout => false, :default_content_type => :css
render :sass, template, options, locals
end
def scss(template, options = {}, locals = {})
options.merge! :layout => false, :default_content_type => :css
render :scss, template, options, locals
end
def builder(template = nil, options = {}, locals = {}, &block)
options[:default_content_type] = :xml
render_ruby(:builder, template, options, locals, &block)

View file

@ -11,7 +11,7 @@
* `sinatra-smart-cache`: update cache header only if arguments are more
restrictive than curent value, set caching headers that way for most helper
methods (i.e. `sass` or `send_file`)
methods (i.e. `send_file`)
* Some verbose logging extension: Log what filters, routes, error handlers,
templates, and so on is used.
@ -26,4 +26,4 @@
* Rewrite of `sinatra-compass`?
* Helpers for HTML escaping and such.
* Helpers for HTML escaping and such.

View file

@ -25,16 +25,6 @@ module Sinatra
@current_engine == :haml
end
# @return [Boolean] Returns true if current engine is `:sass`.
def sass?
@current_engine == :sass
end
# @return [Boolean] Returns true if current engine is `:scss`.
def scss?
@current_engine == :scss
end
# @return [Boolean] Returns true if current engine is `:builder`.
def builder?
@current_engine == :builder

View file

@ -225,7 +225,7 @@ module Sinatra
attr_reader :base, :templates
ALLOWED_ENGINES = [
:erb, :erubi, :haml, :hamlit, :builder, :nokogiri, :sass, :scss,
:erb, :erubi, :haml, :hamlit, :builder, :nokogiri,
:liquid, :markdown, :rdoc, :asciidoc, :radius, :markaby,
:rabl, :slim, :creole, :mediawiki, :coffee, :yajl, :wlang
]

View file

@ -237,7 +237,6 @@ module Sinatra
def self.engines
engines = {
:css => [:sass, :scss],
:xml => [:builder, :nokogiri],
:js => [:coffee],
:html => [:erb, :erubi, :haml, :hamlit, :slim, :liquid, :radius,

View file

@ -46,7 +46,6 @@ EOF
s.add_development_dependency "haml"
s.add_development_dependency "erubi"
s.add_development_dependency "slim"
s.add_development_dependency "sass"
s.add_development_dependency "builder"
s.add_development_dependency "liquid"
s.add_development_dependency "redcarpet"

View file

@ -773,9 +773,9 @@ RSpec.describe Sinatra::Namespace do
it 'sets hashes correctly' do
mock_app do
namespace '/foo' do
set erb: 'o', sass: 'k'
set erb: 'o', haml: 'k'
get '/bar' do
settings.erb + settings.sass
settings.erb + settings.haml
end
end
end

View file

@ -1,2 +0,0 @@
body
color: red

View file

@ -1,115 +0,0 @@
require File.expand_path('helper', __dir__)
begin
require 'sass'
class SassTest < Minitest::Test
def sass_app(options = {}, &block)
mock_app do
set :views, __dir__ + '/views'
set options
get('/', &block)
end
get '/'
end
it 'renders inline Sass strings' do
sass_app { sass "#sass\n background-color: white\n" }
assert ok?
assert_equal "#sass {\n background-color: white; }\n", body
end
it 'defaults content type to css' do
sass_app { sass "#sass\n background-color: white\n" }
assert ok?
assert_equal "text/css;charset=utf-8", response['Content-Type']
end
it 'defaults allows setting content type per route' do
sass_app do
content_type :html
sass "#sass\n background-color: white\n"
end
assert ok?
assert_equal "text/html;charset=utf-8", response['Content-Type']
end
it 'defaults allows setting content type globally' do
sass_app(:sass => { :content_type => 'html' }) {
sass "#sass\n background-color: white\n"
}
assert ok?
assert_equal "text/html;charset=utf-8", response['Content-Type']
end
it 'renders .sass files in views path' do
sass_app { sass :hello }
assert ok?
assert_equal "#sass {\n background-color: white; }\n", body
end
it 'ignores the layout option' do
sass_app { sass :hello, :layout => :layout2 }
assert ok?
assert_equal "#sass {\n background-color: white; }\n", body
end
it "raises error if template not found" do
mock_app { get('/') { sass :no_such_template } }
assert_raises(Errno::ENOENT) { get('/') }
end
it "passes SASS options to the Sass engine" do
sass_app do
sass(
"#sass\n background-color: white\n color: black\n",
:style => :compact
)
end
assert ok?
assert_equal("#sass { background-color: white; color: black; }\n", body)
end
it "passes default SASS options to the Sass engine" do
mock_app do
set :sass, {:style => :compact} # default Sass style is :nested
get('/') { sass("#sass\n background-color: white\n color: black\n") }
end
get '/'
assert ok?
assert_equal "#sass { background-color: white; color: black; }\n", body
end
it "merges the default SASS options with the overrides" do
mock_app do
# default Sass attribute_syntax is :normal (with : in front)
set :sass, {:style => :compact, :attribute_syntax => :alternate }
get('/') { sass("#sass\n background-color: white\n color: black\n") }
get('/raised') do
# retains global attribute_syntax settings
sass(
"#sass\n :background-color white\n :color black\n",
:style => :expanded
)
end
get('/expanded_normal') do
sass(
"#sass\n :background-color white\n :color black\n",
:style => :expanded, :attribute_syntax => :normal
)
end
end
get '/'
assert ok?
assert_equal "#sass { background-color: white; color: black; }\n", body
assert_raises(Sass::SyntaxError) { get('/raised') }
get '/expanded_normal'
assert ok?
assert_equal "#sass {\n background-color: white;\n color: black;\n}\n",
body
end
end
rescue LoadError
warn "#{$!}: skipping sass tests"
end

View file

@ -1,88 +0,0 @@
require File.expand_path('helper', __dir__)
begin
require 'sass'
class ScssTest < Minitest::Test
def scss_app(options = {}, &block)
mock_app do
set :views, __dir__ + '/views'
set options
get('/', &block)
end
get '/'
end
it 'renders inline Scss strings' do
scss_app { scss "#scss {\n background-color: white; }\n" }
assert ok?
assert_equal "#scss {\n background-color: white; }\n", body
end
it 'defaults content type to css' do
scss_app { scss "#scss {\n background-color: white; }\n" }
assert ok?
assert_equal "text/css;charset=utf-8", response['Content-Type']
end
it 'defaults allows setting content type per route' do
scss_app do
content_type :html
scss "#scss {\n background-color: white; }\n"
end
assert ok?
assert_equal "text/html;charset=utf-8", response['Content-Type']
end
it 'defaults allows setting content type globally' do
scss_app(:scss => { :content_type => 'html' }) {
scss "#scss {\n background-color: white; }\n"
}
assert ok?
assert_equal "text/html;charset=utf-8", response['Content-Type']
end
it 'renders .scss files in views path' do
scss_app { scss :hello }
assert ok?
assert_equal "#scss {\n background-color: white; }\n", body
end
it 'ignores the layout option' do
scss_app { scss :hello, :layout => :layout2 }
assert ok?
assert_equal "#scss {\n background-color: white; }\n", body
end
it "raises error if template not found" do
mock_app { get('/') { scss(:no_such_template) } }
assert_raises(Errno::ENOENT) { get('/') }
end
it "passes scss options to the scss engine" do
scss_app do
scss(
"#scss {\n background-color: white;\n color: black\n}",
:style => :compact
)
end
assert ok?
assert_equal "#scss { background-color: white; color: black; }\n", body
end
it "passes default scss options to the scss engine" do
mock_app do
set :scss, {:style => :compact} # default scss style is :nested
get('/') {
scss("#scss {\n background-color: white;\n color: black;\n}")
}
end
get '/'
assert ok?
assert_equal "#scss { background-color: white; color: black; }\n", body
end
end
rescue LoadError
warn "#{$!}: skipping scss tests"
end

View file

@ -1,2 +0,0 @@
#sass
+argle-bargle

View file

@ -1,2 +0,0 @@
#sass
background-color: white

View file

@ -1,3 +0,0 @@
#scss {
background-color: white
}