[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

eRuby and CSS

John Joyce

3/22/2007 5:21:00 AM

Does eRuby parse CSS ?
I'd like to be able to create style sheets that use variables for
repeated values like colors and borders.
I'm curious if eRuby currently has this functionality or not.
Is there some method to use the css link in an xhtml document to
parse the style sheet before sending it to the user-agent?
I know it can be done with css embedded into pages, Blogger does this
with its PHP templating, but that is something I'd rather not do.
Or is this just more trouble than it's worth?

5 Answers

Alex Young

3/22/2007 8:28:00 AM

0

John Joyce wrote:
> Does eRuby parse CSS ?
I don't think that's quite the question you want to ask. eRuby parses
eruby templates to produce text files. Those text files can be pretty
much anything (CSS included).

> I'd like to be able to create style sheets that use variables for
> repeated values like colors and borders.
> I'm curious if eRuby currently has this functionality or not.
> Is there some method to use the css link in an xhtml document to parse
> the style sheet before sending it to the user-agent?
> I know it can be done with css embedded into pages, Blogger does this
> with its PHP templating, but that is something I'd rather not do.
> Or is this just more trouble than it's worth?
>

Take a look at http://rcss.ruby... - I think it does what you're
looking for. It's for Rails, but it should be good education even if
you can't use it directly.

--
Alex

John Joyce

3/22/2007 3:16:00 PM

0

I basically want to have a CSS preprocessor, server-side of course.
(I'd actually like CSS3 to be finished and widespread, but that's
like watching rocks grow)
This looks interesting. Perhaps.
It's on the right track with variables to substitute in for commonly
used values. That's one of the big things lacking in CSS now. But it
doesn't seem as simple as it should/could be.

But perhaps the best approach is building my own ERb solution and
using something with Rails API AssetTagHelper from rails/actionpack/
action_view/helpers/asset_tag_helper.rb
stylesheet_link_tag(*source)
piped through ERb?
Need to sit down with it later!

On Mar 22, 2007, at 5:27 PM, Alex Young wrote:

> John Joyce wrote:
>> Does eRuby parse CSS ?
> I don't think that's quite the question you want to ask. eRuby
> parses eruby templates to produce text files. Those text files can
> be pretty much anything (CSS included).
>
>> I'd like to be able to create style sheets that use variables for
>> repeated values like colors and borders.
>> I'm curious if eRuby currently has this functionality or not.
>> Is there some method to use the css link in an xhtml document to
>> parse the style sheet before sending it to the user-agent?
>> I know it can be done with css embedded into pages, Blogger does
>> this with its PHP templating, but that is something I'd rather
>> not do.
>> Or is this just more trouble than it's worth?
>
> Take a look at http://rcss.ruby... - I think it does what
> you're looking for. It's for Rails, but it should be good
> education even if you can't use it directly.
>
> --
> Alex
>


Andrew Stewart

3/22/2007 5:14:00 PM

0



On 22 Mar 2007, at 15:16, John Joyce wrote:

> I basically want to have a CSS preprocessor, server-side of course.
> (I'd actually like CSS3 to be finished and widespread, but that's
> like watching rocks grow)
> This looks interesting. Perhaps.
> It's on the right track with variables to substitute in for
> commonly used values. That's one of the big things lacking in CSS
> now. But it doesn't seem as simple as it should/could be.

You might be interested in css_dryer, a plugin for Rails which
supports variables and nesting. There's no unusual syntax and the
nesting makes the stylesheet a lot DRYer.

http://blog.airbladesoftware.com/2006/12/11/cssdryer-dry-u...

Regards,
Andy Stewart

khaines

3/22/2007 6:22:00 PM

0

Brian Candler

3/22/2007 8:09:00 PM

0

On Thu, Mar 22, 2007 at 02:21:18PM +0900, John Joyce wrote:
> Does eRuby parse CSS ?

eRuby doesn't parse anything really, apart from extracting <% .. %> tags.

There's nothing to stop you writing CSS files that have snippets of
<%= ... %> embedded in them.

As it happens, I've just been generating Cisco IOS configuration files using
erb within Rails.

!
interface FastEthernet 0/0
ip address <%= lan_ipaddr %> <%= lan_netmask %>

Regards,

Brian.