-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure Sass support #473
Merged
Merged
Pure Sass support #473
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
263dc71
rake convert
glebm c58415e
Sass-only support
glebm 8c7b1a9
ie-hex-str
glebm a49f4cb
Update README.md
glebm 08f9199
No ruby required, hopefully ($bootstrap-sass-asset-helper)
glebm 8c08d4e
update dummy page
glebm 8b9e775
Merge branch 'pr-477'
glebm cc2ec7e
rake convert
glebm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
require 'sass' | ||
require 'bootstrap-sass' | ||
|
||
module Sass::Script::Functions | ||
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9 | ||
# returns an IE hex string for a color with an alpha channel | ||
# suitable for passing to IE filters. | ||
def ie_hex_str(color) | ||
assert_type color, :Color | ||
alpha = (color.alpha * 255).round | ||
alphastr = alpha.to_s(16).rjust(2, '0') | ||
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase) | ||
end | ||
declare :ie_hex_str, [:color] | ||
def twbs_font_path(source) | ||
twbs_asset_path source, :font | ||
end | ||
declare :twbs_font_path, [:source] | ||
|
||
def twbs_image_path(source) | ||
twbs_asset_path source, :image | ||
end | ||
declare :twbs_image_path, [:source] | ||
|
||
def twbs_asset_path(source, type) | ||
url = if Bootstrap.asset_pipeline? && (context = sprockets_context) | ||
context.send(:"#{type}_path", source.value) | ||
elsif Bootstrap.compass? | ||
send(:"#{type}_url", source, Sass::Script::Bool.new(true)).value | ||
end | ||
|
||
# sass-only | ||
url ||= source.value.gsub('"', '') | ||
Sass::Script::String.new(url, :string) | ||
end | ||
declare :twbs_asset_path, [:source] | ||
|
||
unless Sass::Script::Functions.instance_methods.include?(:ie_hex_str) | ||
# polyfill sass < 3.2.6 (taken from sass 3.2.12): | ||
def ie_hex_str(color) | ||
assert_type color, :Color, :color | ||
alpha = (color.alpha * 255).round.to_s(16).rjust(2, '0') | ||
Sass::Script::String.new("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase) | ||
end | ||
declare :ie_hex_str, [:color] | ||
end | ||
|
||
protected | ||
|
||
def sprockets_context | ||
# Modern way to get context: | ||
if options.key?(:sprockets) | ||
options[:sprockets][:context] | ||
# Compatibility with sprockets pre 2.10.0: | ||
elsif (importer = options[:importer]) && importer.respond_to?(:context) | ||
importer.context | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Bootstrap | ||
VERSION = '3.0.2.1' | ||
BOOTSTRAP_SHA = '463343af63344dbbc3db04f40b0b804baa919b7e' | ||
BOOTSTRAP_SHA = 'cc6951fa15ab990b5d90edd7acc9f1bbf2f16875' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to kick an old PR, but this
if
syntax is invalid Sass and blows up node-sass/libsass compilationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome that you tried this on node-sass! How does it fail exactly? Would you add a test for compiling with it?
The syntax is valid and is specified here: http://sass-lang.com/documentation/Sass/Script/Functions.html#if-instance_method
It also appears to be supported by libsass: https://github.com/hcatlin/libsass/blob/master/functions.cpp#L959-L961
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't realize there was an
IIF
like function in Sass. The actual error isbootstrap/mixins:336: error: non-terminal statement or declaration must end with ';'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does look like the
if
instance is available in libsass https://github.com/hcatlin/libsass/blob/master/functions.cpp#L959There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to #494