Thx Chris,

It works :-)

I added the next lines to the bottom of my config.rb

module Sass::Script::Functions
  def gsub(string, regexp, replacement)
    Sass::Script::String.new(string.value.gsub(Regexp.new(regexp.value),
replacement.value))
  end
end

And used it like this:

$someComputedColor: #222222;

$color:  gsub(#{$someComputedColor}, "^#", "");

background: url("
http://jqueryui.com/themeroller/images/?new=#{$color}&w=256&h=240&f=png&fltr[]=rcd|256&fltr[]=mask|icons/icons.png
");

On Tue, Feb 22, 2011 at 3:06 AM, Chris Eppstein <ch...@eppsteins.net> wrote:

> The simplest approach is to just drop that snippet into your compass
> config.
>
> You'll need to coerce your color to a string before passing it to that
> function. Any value can be coerced to a string like this: "#{$value}"
>
> chris
>
> On Mon, Feb 21, 2011 at 5:47 PM, Mike <mikebranderho...@gmail.com> wrote:
>
>> Thx Chris,
>>
>> Do I put gsub_ext.rb next to config.rb?
>>
>> I just made a simple example for my question. At the moment I make
>> jQuery UI SASS ready. With a custom made themeroller but I still have
>> to get the generated icons from themeroller.
>>
>> background: url("http://jqueryui.com/themeroller/images/?
>> new=222222&w=256&h=240&f=png&fltr[]=rcd|256&fltr[]=mask|icons/
>> icons.png");
>>
>> Notice 222222, this is the place where I put the user defined color to
>> generate the icons.
>>
>> Later, I'll grep the sprite with php and save it local on server.
>>
>> On Feb 22, 2:24 am, Chris Eppstein <ch...@eppsteins.net> wrote:
>> > There's no reliable way of accomplishing this. First, Sass doesn't
>> expose
>> > many string operations and second, different output modes of sass will
>> > generate different output values for colors of the same input color. If
>> you
>> > must, check out this gist where I show you how you can add the gsub
>> function
>> > to sass:https://gist.github.com/790592
>> >
>> > It seems like you want to generate png of a certain color. If so you
>> might
>> > enjoy this compass plugin that does it transparently (pun intended) for
>> you:
>> >
>> > https://github.com/aaronrussell/compass-rgbapng
>> >
>> > <https://github.com/aaronrussell/compass-rgbapng>Chris
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Mon, Feb 21, 2011 at 4:17 PM, Mike <mikebranderho...@gmail.com>
>> wrote:
>> > > I'm just new to SASS and SCSS and for now I'm blown away, this is just
>> > > fantastic.
>> > > Now, what I'm looking for is a way to remove the # from the color at a
>> > > certain time.
>> > > In a SCSS file I'm using and calculating away with a certain color ex.
>> > > #ffffff.
>> > > I'm using background url params to access the colored image whithout
>> > > #.
>> >
>> > > $color = #ffffff; background: url("img/#{$color}.png");
>> >
>> > > How can remove #?
>> >
>> > > To get this: background: url("img/ffffff.png");
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Haml" group.
>> > > To post to this group, send email to haml@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > haml+unsubscr...@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/haml?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Haml" group.
>> To post to this group, send email to haml@googlegroups.com.
>> To unsubscribe from this group, send email to
>> haml+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/haml?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to haml@googlegroups.com.
> To unsubscribe from this group, send email to
> haml+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to haml@googlegroups.com.
To unsubscribe from this group, send email to haml+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to