Last active
December 17, 2015 18:18
-
-
Save 2no/5651894 to your computer and use it in GitHub Desktop.
Sass で sprintf。compass なら、config.rb に sprintf.rb の内容を書いておくと使える。
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
$tmp: ""; | |
.sample1:after{ | |
$tmp: sprintf("%02d,%02d", 1, 2); | |
content: "#{$tmp}"; | |
} | |
// 結果:content: "01,02"; | |
$tmp: ""; | |
.sample1:after{ | |
$tmp: sprintf("%.5s", foobar); | |
content: "#{$tmp}"; | |
} | |
// 結果:content: "fooba"; |
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
require "sass" | |
module WakuworksFunctions | |
def sprintf(format, *args) | |
assert_type format, :String | |
assert_type args, :Array | |
Sass::Script::String.new(format.value%args) | |
end | |
end | |
module Sass::Script::Functions | |
include WakuworksFunctions | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment