Not a problem. Notice now that sass has an innate understanding of
units now, so you can convert units like so:
font-size = 1em * 10px / 18px
Also, sass on the edge has arguments for mixins so you can abstract
this pattern:
=em-font-size(!size, !base = 12px)
font-size = 1em * !size / !base
Then you can simply write:
div.bigger
+em-font-size(18px)
=> div.bigger {font-size: 1.5em;}
chris
Hunt & pecked on my iPhone... Sorry if it's brief!
On Dec 9, 2008, at 2:56 AM, Niels Ganser <[EMAIL PROTECTED]> wrote:
>
> Now this was a classic fail.
>
> Forgive me for not living on the edge, the issue has of course been
> fixed in
> http://github.com/nex3/haml/commit/689bb9e68305a09a84533e714cea0f319369a87f
> .
>
> Sorry for wasting your time with my lengthy first mail,
> Niels
>
> On Dec 9, 11:43 am, Niels Ganser <[EMAIL PROTECTED]> wrote:
>> Hi everyone,
>>
>> I've been using Haml & Sass for a while now and, after a small
>> learning curve, both have simplified my life quite a bit. Especially
>> useful is Sass's ability to calculate on the fly. One way I use this
>> is by setting my base font size in px as a Sass constant and later in
>> my stylesheets divide various other pixel values (e.g. the width of a
>> logo) by the base font size in order to get an em value out of it.
>>
>> There is one big problem with this in the current Sass
>> implementation:
>> Floats! Consider the following:
>> (a) :height = (7/14)+em => parses as height: 0
>> (b) :height = (7.0/14.0)+em => parses as height: 0.5em
>> (c) !a = 7.0
>> !b = 14.0
>> :height = (!a/!b)+em => parses as height: 0
>>
>> While I would say that (a) and (b) can reasonably be expected, (c),
>> in
>> my eyes, breaks the logic.
>>
>> The implementation in question is to be found in
>> Sass::Constant::Number#to_s. Here, Sass *mathematically* decides
>> whether a given value is a float or an integer instead of accepting
>> how it had been *programatically* defined. Meaning that while
>> mathematically 14.0 is indeed an integer (14.0 % 1 == 0.0), if I, the
>> programmer, write it as 14.0 I usually did so specifically to have it
>> handled as a float.
>>
>> Am I correct to assume that Sass performs the conversion to integers
>> purely in order to clean up its output? If so I would suggest simply
>> killing line lib/sass/constant/number.rb:60 since the "eyecandy"
>> upside of having 14 instead of 14.0 in the output does not seem to
>> justify any elaborate checks.
>>
>> Additionally I would even welcome having all arithmetic operations
>> result in floats. In my eyes 7/14 should always result in 0.5.
>> However, there probably is a good reason why Sass does behave
>> differently? I must insist though that Sass should respect my choice
>> to use floats if it is as explicit as writing 7.0.
>>
>> Best,
>> Niels.
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---