Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Proxy #3

Closed
judofyr opened this issue Jul 14, 2009 · 2 comments
Closed

CSS Proxy #3

judofyr opened this issue Jul 14, 2009 · 2 comments

Comments

@judofyr
Copy link
Owner

judofyr commented Jul 14, 2009

div.footer! # => div(:id => :footer)
div.important.news!(:style => "...") # => div(:class => :important, :id => :news, :style => "...")

I love these! Parkaby::Processor in my repo is currently able to catch these, so I just need some glue in Parkaby::Generator!

@judofyr
Copy link
Owner Author

judofyr commented Jul 14, 2009

These can be kinda hard to implement 100% correctly without checking everything at runtime. Have a look at this example:

# Input:
thing = :class
div(thing => 'foo')

# Result:
thing = :class
"<div #{thing}='foo'/>" 

Simple stuff. Now, what about this:

thing = :class
div.cool(thing => 'foo')

thing can be anything, so the correct way would be:

"<div#{{thing => 'foo'}.map do |k, v|
  if k == :class
    "class='cool #{v}'"
  else
    "#{k}='#{v}'"
  end
end}/>"

That's slower, and in order to stay fast I would have to add more code to figure out when I know that none of the keys can possibly include :class (and use the simple version).

Right now I think I'll do it the easy way:

"<div class='cool' #{thing}='foo'/>"

Basically: Don't use :class/:id together with CSS proxy. I'm going to fix this later, but it's not that important for 0.1.

@judofyr
Copy link
Owner Author

judofyr commented Jul 20, 2009

Naive implementation of CSS proxies. Closed by 9762072.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant