[Lift] data-lift question

392 views
Skip to first unread message

Peter Petersson

unread,
Dec 22, 2011, 4:14:06 AM12/22/11
to lif...@googlegroups.com
Hi

I am in the process of switching to use data-lift="xxxx" in favor for class="lift:xxxx" and it works great.
However I expected it to work on the body tag as well but I could not get it to parse, am I wrong in assuming it should work ? 

For instance take a look at my
Basic-SquerylRecord-User-Setup example
https://github.com/karma4u101/Basic-SquerylRecord-User-Setup/blob/master/src/main/webapp/index.html

...here I have switched to data-lift every ware possible expect for the following:

<body class="lift:content_id=main">
witch I assumed I would be able to write:
<body data-lift="content_id=main">
but it dose not work.

best regards
   Peter Petersson

Jeppe Nejsum Madsen

unread,
Dec 22, 2011, 4:48:27 AM12/22/11
to lif...@googlegroups.com
Peter Petersson <peterss...@gmail.com> writes:

I think the data-lift only works for snippets and the content_id is not
a snippet, but a special-cased marker.

It would be nice to support not using the class attribute for anything
Lift related.

Otoh, since content_id is not a snippet perhaps we should not use
data-lift="content_id=main" but something else like data-lift-content-id="main"

Wdyt?

/Jeppe

Peter Petersson

unread,
Dec 22, 2011, 5:17:12 AM12/22/11
to lif...@googlegroups.com
Thanks for the explanation Jeppe, now that I realize it is a
"special-cased marker" and not a snippet it makes sense.
Yes I agree that it would be great to be able to use data-lift for
everything lift related in the templates.

Your suggestions is good, personally I think sticking with data-lift
would be the cleanest approach from a user perspective as it would
probably feel more natural and generate less questions on this list.

How about, in addition to this "special-cased marker", add a new built
in snippet, allowing for a alternative syntax and use it something like
this <body data-lift="content?id=main"> ?

best regards
Peter Petersson

>
> /Jeppe
>

David Pollak

unread,
Dec 22, 2011, 1:21:59 PM12/22/11
to lif...@googlegroups.com
On Thu, Dec 22, 2011 at 2:17 AM, Peter Petersson <peterss...@gmail.com> wrote:
On 2011-12-22 10:48, Jeppe Nejsum Madsen wrote:
Peter Petersson<petersson.peter@gmail.com>  writes:

THe marker cannot be a snippet.  This stuff is evaluated before the snippet mechanism and order is important in this case.

I like Jeppe's approach and it separates the marker into a different attribute from the snippet stuff.  Can you or Jeppe open a ticket on this?  I'll take it unless Jeppe feels like he wants to do the work.
 

best regards
  Peter Petersson



/Jeppe


--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


Peter Petersson

unread,
Dec 23, 2011, 4:11:57 AM12/23/11
to lif...@googlegroups.com
On 2011-12-22 19:21, David Pollak wrote:
On Thu, Dec 22, 2011 at 2:17 AM, Peter Petersson <peterss...@gmail.com> wrote:
On 2011-12-22 10:48, Jeppe Nejsum Madsen wrote:
Peter Petersson<peterss...@gmail.com>  writes:

Okey thanks for the explanation, there is a reason for everything ;) and I was suspecting something on the line of that could be the case.



I like Jeppe's approach and it separates the marker into a different attribute from the snippet stuff.  Can you or Jeppe open a ticket on this?  I'll take it unless Jeppe feels like he wants to do the work.

I have put together a ticket #1173 "Extending the data-lift html5 mechanism" and initially assigned it to David
http://www.assembla.com/spaces/liftweb/tickets/1173-extending-the-data-lift-html5-mechanism

best regards
   Peter Petersson

Denis Nevmerzhitsky

unread,
Jan 12, 2012, 10:26:20 AM1/12/12
to lif...@googlegroups.com
Hi!

I have another approach.
Using html5's data attribute we don't need mark <body> anymore. It will be more convenient to mark element directly. Like this:
<div class="content" data-lift-marker="content">
or this:
<div class="content" data-lift-content="true">

data-lift-marker is more flexible, i.e. it can have additional values like 'content-wrapper' (it means that children of marked element should be used) or others for future features.

What do you think?
I don't know about performance, but I'm sure that it shouldn't be much slower (if it will be) than body-marking version.

Best regards

David Pollak

unread,
Jan 12, 2012, 12:22:37 PM1/12/12
to lif...@googlegroups.com
The problem with this approach is that it requires walking the entire document to search for the tag.  Looking for something in the <body> tag is computationally cheap (the <body> tag is almost always the first or second tag in the children of the root tag.)  Speed counts in making this decision *and* it's also easier for a human to look at the attribute in the <body> tag and understand how Lift will process the document.

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

Denis Nevmerzhitsky

unread,
Jan 13, 2012, 3:15:44 AM1/13/12
to lif...@googlegroups.com
Hi, David!

Thx for the answer.
I see sense in your words (but i still think that my variant can be as fast as body variant).
What about compromise? Two markers: one for body, second for content. The main goal is do not use html's id. Like this:
<body data-lift-marker="fake-body">
<div data-lift-marker="content">
</div>
</body>
(names of marker do not matter)

David Pollak

unread,
Jan 13, 2012, 11:13:55 AM1/13/12
to lif...@googlegroups.com
I'm not adding yet another mechanism for doing this.  Lift is often criticized for having too many ways to do everything.  Adding another marker convention doesn't have any material benefit that I can see and increases the amount of "but what's the right way" concern in an end user.  Sorry.

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

Denis Nevmerzhitsky

unread,
Jan 16, 2012, 6:20:49 AM1/16/12
to lif...@googlegroups.com
Hi!

ok, no problems!
Reply all
Reply to author
Forward
0 new messages