Yet another Menu.item snippet question…

Showing 1-10 of 10 messages
Yet another Menu.item snippet question… Viktor Hedefalk 10/3/11 3:36 AM
I'm cleaning up some old stuff and I have this:

<lift:Menu.item name="LostPasswordApplicant">Glömt lösenord?</lift:Menu.item>

which I would like to replace with CSS bindings. But

<a class="lift:Menu.item?name=LostPasswordApplicant">Glömt lösenord?</a>

turns into two anchors:

<a href="/customer/lost_password"></a><a href="#">Glömt lösenord?</a>

which isn't what I want. This kindof works:

 <span class="lift:Menu.item?name=LostPasswordApplicant">Glömt lösenord?</span>
->
<a href="/customer/lost_password"><span>Glömt lösenord?</span></a>

But I'd much rather drop the span due to styling issues.

I'm feeling thick as a brick again…

Thanks,
Viktor

Re: [Lift] Yet another Menu.item snippet question… Ján Raška 10/3/11 4:48 AM
Hi Victor,

briefly looking at the code, Menu.item generates a link, using input NodeSeq as its content. However with CSS bindings, element containing a lift:Snippet class is also included in the input NodeSeq, as opposed to classical binding where <lift:Snippet> tag was excluded. 

I don't know if there is a way to ensure, only children are passed as input NodeSeq (if no, it'd be a nice feature I think), but supposing there is no other way, you could do it by making a wrapper snippet that'd look something like this:

import net.liftweb.util._
import Helpers._
import net.liftweb.builtin.snippet.Menu
import scala.xml._

class MyMenu 
{
def item =
{
  "*" #> ((ns:NodeSeq) => if(ns.isInstanceOf[Elem]) Menu.item(ns.asInstanceOf[Elem].child) else Menu.item(ns))
}
}


Hope it helps

Jan

Re: [Lift] Yet another Menu.item snippet question… Viktor Hedefalk 10/3/11 5:40 AM
Hehe, definitely helped, I just grabbed your code :D

I'm thinking the difference you're describing is kind of an impedance
mismatch between css and old style binding and many of these built-in
snippets I guess are made for the old style of binding. Or maybe they
aren't _that_ many really. But then again, there might be some low
fruit making them easier to use out of the box for css binding…? I
mean for attracting newcomers if we say css binding is the way to go.
I guess this has already been discussed though :)

Thanks again!
Viktor

Re: [Lift] Yet another Menu.item snippet question… David Pollak 10/3/11 9:34 AM
Please open a ticket that adds a flag to the Menu.item code that swallows the surrounding Elem.

Also, as a point of reference, you are not using CSS Selector Transforms, but instead, the invocation mechanism is Lift's "Designer Friendly" snippet invocation.  Designer friendly does not imply CSS Selector Transforms nor do CSS Selector Transforms imply Designer Friendly.  However, the two work best together.


--
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



--
Lift, the simply functional web framework http://liftweb.net

Re: [Lift] Yet another Menu.item snippet question… Ján Raška 10/3/11 11:22 AM
Wouldn't it be possible to make this as a general feature for all snippets? So that I could add that flag anywhere and surrounding Elem would be swallowed before it is passed to the snippet method? I have quite many snippets with this flag coded in, so I think it would be handy for more people from Lift community.
Re: [Lift] Yet another Menu.item snippet question… Viktor Hedefalk 10/3/11 12:43 PM
> Also, as a point of reference, you are not using CSS Selector Transforms,
> but instead, the invocation mechanism is Lift's "Designer Friendly" snippet
> invocation.  Designer friendly does not imply CSS Selector Transforms nor do
> CSS Selector Transforms imply Designer Friendly.  However, the two work best
> together.

Thanks for pointing this out. Of course they are not the same, I just
started using them simultaneously. I shouldn't be posting when my
brain has gone home :)

Ticket opened (I assigned it to DPP):
http://www.assembla.com/spaces/liftweb/tickets/1126-add-flag-to-menu-item-that-swallows-the-surrounding-elem-

Thanks,
Viktor

Re: [Lift] Yet another Menu.item snippet question… David Pollak 10/3/11 3:22 PM


On Mon, Oct 3, 2011 at 11:22 AM, Ján Raska <ras...@gmail.com> wrote:
Wouldn't it be possible to make this as a general feature for all snippets? So that I could add that flag anywhere and surrounding Elem would be swallowed before it is passed to the snippet method? I have quite many snippets with this flag coded in, so I think it would be handy for more people from Lift community.

When it's your snippet, you control it, so making it general doesn't seem to be optimal to me, but if others want the flag, we can look into it.
This message has been hidden because it was flagged for abuse.
Re: [Lift] Yet another Menu.item snippet question… Jeppe Nejsum Madsen 10/10/11 7:16 AM
Naftoli Gugenheim <nafto...@gmail.com> writes:

> I think some other forms of this issue have come up before. Perhaps it was
> forms and lift:loc? Jeppe, do you know what I'm thinking of?


Maybe :-) Haven't read all the details in this thread.

I did add a method to the Loc snippet so you could write

<h2 class="lift:Loc.i">MyHeading</h2>

I.e. keep the h2 elem and use MyHeading as property key. This makes for
nice designer friendly localization.

I think the same could be used with the Menu snippet. But how to solve
the translation issue then?

One option could be to allow:

<a class="lift:Menu.item">LostPasswordApplicant</a>

which would add the correct href and translated menu name...

/Jeppe

This message has been hidden because it was flagged for abuse.