Merge pull request #782 from MoOx/stable

Add ability to append stuffs after font urls
This commit is contained in:
Chris Eppstein 2012-03-13 22:41:05 -07:00
commit 80ebf71782
4 changed files with 19 additions and 8 deletions

View File

@ -1,6 +1,6 @@
@import compass/css3 @import compass/css3
+font-face("Blooming Grove", font-files("examples/bgrove.ttf", truetype, "examples/bgrove.otf", opentype)) +font-face("Blooming Grove", font-files("examples/bgrove.ttf", "examples/bgrove.otf"))
.example .example
font-family: "Blooming Grove" font-family: "Blooming Grove"

View File

@ -16,13 +16,10 @@ documented_functions:
#font-files.helper #font-files.helper
%h3 %h3
%a(href="#font-files") %a(href="#font-files")
font-files([<span class="arg">$font</span>, <span class="arg">$format</span>]*) font-files([<span class="arg">$font</span>]*)
.details .details
%p %p
The <code>font-files</code> function takes any even number of arguments. The <code>font-files</code> function takes a list of arguments containing the path to each font files relative to your project's font directory.
For each pair of arguments, the first is the path to the font file
relative to your project's font directory and the second is the format of
that font.
%p %p
This helper is used with the <a href="/reference/compass/css3/font_face/#mixin-font-face"><code>font-face</code> mixin</a> This helper is used with the <a href="/reference/compass/css3/font_face/#mixin-font-face"><code>font-face</code> mixin</a>
and is what makes it possible to pass any number of font files. and is what makes it possible to pass any number of font files.

View File

@ -5,7 +5,8 @@ module Compass::SassExtensions::Functions::FontFiles
:opentype => 'opentype', :opentype => 'opentype',
:ttf => 'truetype', :ttf => 'truetype',
:truetype => 'truetype', :truetype => 'truetype',
:svg => 'svg' :svg => 'svg',
:eot => 'embedded-opentype'
} }
def font_files(*args) def font_files(*args)
@ -24,7 +25,8 @@ module Compass::SassExtensions::Functions::FontFiles
if FONT_TYPES.key? type if FONT_TYPES.key? type
skip_next = true skip_next = true
else else
type = arg.to_s.split('.').last.gsub('"', '').to_sym # let pass url like font.type?thing#stuff
type = arg.to_s.split('.').last.gsub(/(\?(.*))?(#(.*))?"/, '').to_sym
end end
if FONT_TYPES.key? type if FONT_TYPES.key? type

View File

@ -126,6 +126,18 @@ class SassExtensionsTest < Test::Unit::TestCase
evaluate("font-files('/font/name.woff')") evaluate("font-files('/font/name.woff')")
end end
assert_nothing_raised Sass::SyntaxError do
evaluate("font-files('/font/name.svg#fontId')")
end
assert_nothing_raised Sass::SyntaxError do
evaluate("font-files('/font/name.eot?#iefix')")
end
assert_nothing_raised Sass::SyntaxError do
evaluate("font-files('/font/name.svg?mightbedynamic=something%20+escaped#fontId')")
end
assert_raises Sass::SyntaxError do assert_raises Sass::SyntaxError do
evaluate("font-files('/font/name.ext')") evaluate("font-files('/font/name.ext')")
end end