Merge pull request #782 from MoOx/stable
Add ability to append stuffs after font urls
This commit is contained in:
commit
80ebf71782
@ -1,6 +1,6 @@
|
||||
@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
|
||||
font-family: "Blooming Grove"
|
||||
|
@ -16,13 +16,10 @@ documented_functions:
|
||||
#font-files.helper
|
||||
%h3
|
||||
%a(href="#font-files")
|
||||
font-files([<span class="arg">$font</span>, <span class="arg">$format</span>]*)
|
||||
font-files([<span class="arg">$font</span>]*)
|
||||
.details
|
||||
%p
|
||||
The <code>font-files</code> function takes any even number of arguments.
|
||||
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.
|
||||
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.
|
||||
%p
|
||||
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.
|
||||
|
@ -5,7 +5,8 @@ module Compass::SassExtensions::Functions::FontFiles
|
||||
:opentype => 'opentype',
|
||||
:ttf => 'truetype',
|
||||
:truetype => 'truetype',
|
||||
:svg => 'svg'
|
||||
:svg => 'svg',
|
||||
:eot => 'embedded-opentype'
|
||||
}
|
||||
|
||||
def font_files(*args)
|
||||
@ -24,7 +25,8 @@ module Compass::SassExtensions::Functions::FontFiles
|
||||
if FONT_TYPES.key? type
|
||||
skip_next = true
|
||||
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
|
||||
|
||||
if FONT_TYPES.key? type
|
||||
|
@ -126,6 +126,18 @@ class SassExtensionsTest < Test::Unit::TestCase
|
||||
evaluate("font-files('/font/name.woff')")
|
||||
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
|
||||
evaluate("font-files('/font/name.ext')")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user