Skip to content

Support data-name attribute in CSS Selector Transforms #1185

Closed
dpp opened this Issue Jan 26, 2012 · 20 comments

6 participants

@dpp
Lift Web Framework member
dpp commented Jan 26, 2012

Support data-name attribute selection with a shortcut in CSS Selector Transforms so that id and class do not have to be over-loaded with server-side meaning. So, perhaps ";foo" #> "bar" replaces all elements with data-name="foo" with "bar"

@dpp dpp was assigned Mar 1, 2012
@steve52
steve52 commented Feb 13, 2013

Hi, just wondering if this is still planned to be in 2.5-M5. I really like this idea!

@nafg
nafg commented Feb 13, 2013
@Shadowfiend
Lift Web Framework member

Lift 3.0 will introduce any-attribute snippet binding (see http://blog.goodstuff.im/lift_30 ). Personally, I think the close mapping to CSS is a good thing, not a bad one. You can match arbitrary attributes in the actual transforms by doing e.g. "data-name=foo" #> "bar".

@nafg
nafg commented Feb 13, 2013
@steve52
steve52 commented Feb 13, 2013

Sure you can already match arbitrary attributes, but "data-name=foo" #> "bar" can clutter up your snippet if you use it all over. Have a special symbol (like # for id and . for classes) would make our snippets clean and encourage people not to use ids and classes for lift purposes.

I believe what we're talking about here is:
"data-name=foo" #> "bar"
vs.
";foo" #> "bar"

@nafg
nafg commented Feb 13, 2013
@Shadowfiend
Lift Web Framework member

Not sure if this conversation should be moved to the list… I have three points to make:

  • I'm opposed to adding more shorthands, as it adds more learning curve.
  • I'm even more opposed to ; as the sigil—something about the look of it bugs me as a sigil.
  • In my experience, properly structured semantic HTML has never clashed with my need for Lift bind points except for situations where I need to replace one word in a sentence (and arguably in these cases Lift should bind the whole sentence instead of dropping a span in the middle of it as I often do).

I'd be curious to see the markup and what you're wanting to do with it to see if there's a better way to improve the markup rather than adding complexity to Lift. If you're willing to share it, I would suggest posting to the Lift list and referencing this issue.

@steve52
steve52 commented Feb 13, 2013

Basically the idea is to further separate design from code. CSS classes should be used for.. well.... CSS. By using it for css AND lift, things can get muddled. For example, you could have a conflict where your designer wants to change the name of a class, but you're using it in a lift snippet. By separating them out and leaving classes and ids for css and js and using a data attribute for lift stuff, you can avoid some confusion and allow your designer to do his work and your coder to do his without them messing up each other up.

You should read throguh https://groups.google.com/forum/?fromgroups=#!topic/liftweb/lDY9NTob2W0.

I believe that's the thread where this idea got started.

@steve52
steve52 commented Feb 13, 2013

I agree, this is becoming a conversation that should probably be taking place in the LIft Group rather than here.

This has already been discussed in a thread (https://groups.google.com/forum/?fromgroups=#!topic/liftweb/lDY9NTob2W0). That's why DPP created this issue. But that was awhile ago, so I was just wondering if there was still a plan to include this in a future release.

@Shadowfiend
Lift Web Framework member

For what it's worth, I read through the thread before posting here :) I just wasn't convinced.

@nafg
nafg commented Feb 13, 2013
@andreak
Lift Web Framework member
@dpp
Lift Web Framework member
dpp commented Feb 14, 2013

You can already use data-name:

"data-name=wombat" #> thing

It's just there's no shortcut for it.

@steve52
steve52 commented Feb 14, 2013

@andreak - Yeah, we use something similar at my job. Any class names that are used for lift transforms have a "_" in front. e.g. class="_addresses addresses", class="_name name" then in the snippet "._name" #> user.name

@dpp - So is there still a plan to make a shortcut for data-name and include it in a future lift release?

@andreak
Lift Web Framework member
@dpp
Lift Web Framework member
dpp commented Feb 14, 2013

I don't know what you mean by "plans." The ticket is open and I haven't closed it.

I write Lift code that I need or that I'm paid to write. If I'm in the CSS Selector Transforms, I may drop this code in. Maybe another committer will get to it before I have a chance.

In the mean time, you can write a method (and do implicit magic with it) to transform ";xxxx" ##> xxx into "data-name=xxxx" #> xxxx

@steve52
steve52 commented Feb 14, 2013

Fair enough. Since it's open and marked at 2.5 M5, I was just curious if that meant it was probably going to be in that release.

I thought about writing an implicit method and doing it myself, but my scala-foo is still weak. Some tips would be appreciated or I can post to the google group to get some help!

@Shadowfiend
Lift Web Framework member

This looks like it's been in Lift 3 for a while, and this thread indicates that it's available in Lift 2.6, as well (unfortunately :p).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.