Skip to content
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

added sassify and scssify filters for converting sass and scss strings to css #2739

Merged
merged 1 commit into from
Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/jekyll/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ def markdownify(input)
converter.convert(input)
end

# Convert a Sass string into CSS output.
#
# input - The Sass String to convert.
#
# Returns the CSS formatted String.
def sassify(input)
site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::Converters::Sass)
converter.convert(input)
end

# Convert a Scss string into CSS output.
#
# input - The Scss String to convert.
#
# Returns the CSS formatted String.
def scssify(input)
site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::Converters::Scss)
converter.convert(input)
end

# Format a date in short format e.g. "27 Jan 2011".
#
# date - the Time to format.
Expand Down
8 changes: 8 additions & 0 deletions test/test_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ def initialize(opts = {})
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.markdownify("something **really** simple")
end

should "sassify with simple string" do
assert_equal "p {\n color: #123456; }\n", @filter.sassify("$blue:#123456\np\n color: $blue")
end

should "scssify with simple string" do
assert_equal "p {\n color: #123456; }\n", @filter.scssify("$blue:#123456; p{color: $blue}")
end

should "convert array to sentence string with no args" do
assert_equal "", @filter.array_to_sentence_string([])
end
Expand Down