Isn't this similar to Option.mapOrElse that you opposed on the scala mailing
list? :)
alex
On Mon, Dec 1, 2008 at 9:55 AM, David Pollak
<[EMAIL PROTECTED]>wrote:
> I've added def dmap[B](dflt: => B)(f: A => B): B to Cans:
>
> S.param("foo").dmap(5)(toInt)
>
>
> On Fri, Nov 28, 2008 at 6:53 AM, Derek Chen-Becker <[EMAIL PROTECTED]>wrote:
>
>> I have to say, I love this "Can->map->openOr" idiom. I use it all of the
>> time in my code for parameter handling, etc.
>>
>> Derek
>>
>>
>> On Fri, Nov 28, 2008 at 5:51 AM, Marius <[EMAIL PROTECTED]> wrote:
>>
>>>
>>> Yup ... or you can have
>>>
>>> val count = S.attr("count").map(_.toInt) openOr 5
>>>
>>> Br's,
>>> Marius
>>>
>>> On Nov 28, 2:15 pm, Tim Perrett <[EMAIL PROTECTED]> wrote:
>>> > Wow, I cant belive I didnt know about that - thats pretty fricking
>>> > useful!! Presumably:
>>> >
>>> > val count: Int = S.attr("count") match {
>>> > case Full(item) => item.toInt
>>> > case Empty => 5
>>> > }
>>> >
>>> > Is the normal idiom?
>>> >
>>> > Cheers
>>> >
>>> > Tim
>>> >
>>> > On Nov 27, 11:34 pm, Tim Perrett <[EMAIL PROTECTED]> wrote:
>>> >
>>> > > Hmm interesting! This I'm not familiar with - I'll give it a whirl
>>> > > tomorow.
>>> >
>>> > > Cheers, Derek
>>> >
>>> > > Sent from my iPhone
>>> >
>>> > > On 27 Nov 2008, at 22:11, "Derek Chen-Becker" <[EMAIL PROTECTED]>
>>>
>>> > > wrote:
>>> >
>>> > > > I thought that S.attr could already be used to get the attributes
>>> on
>>> > > > a tag. Am I misunderstanding what you're getting at?
>>> >
>>> > > > Derek
>>> >
>>> > > > On Thu, Nov 27, 2008 at 11:38 AM, Tim Perrett <
>>> [EMAIL PROTECTED]>
>>> > > > wrote:
>>> >
>>> > > > Guys,
>>> >
>>> > > > Im currently re-designing the whole bloglite publishing engine im
>>> > > > writing and one of the things im considering is how I could
>>> possible
>>> > > > extend lifts tagging mechanism so that users could decide on there
>>> own
>>> > > > dynamic content, rather than just have textile based articles.
>>> >
>>> > > > For instance, a list of latest blogs on the home page of a site:
>>> this
>>> > > > might be a mixture of static content, and then the dynamic list of
>>> > > > course. My original plan was to provide a bunch of default
>>> snippets;
>>> > > > stuff like "list all the child pages of this page" type thing, but
>>> im
>>> > > > pretty sure that simply wont be flexible enough.
>>> >
>>> > > > I know its very JSP like, but it does seem like we could add on
>>> > > > functionality for things such as deciding how many items should be
>>> > > > within a list. The programmer builds his app to say "heres a list
>>> of
>>> > > > articles", but surley, its up to the designer to decide how many
>>> > > > should be displayed on that page?
>>> >
>>> > > > given this snippet:
>>> >
>>> > > > class Articles {
>>> > > > def list(max: Int) = {
>>> > > > ... // fetch articles
>>> > > > }
>>> > > > }
>>> >
>>> > > > that it would then be sensible for the designer to be able to do:
>>> >
>>> > > > <lift:articles.list max="5" />
>>> >
>>> > > > What is the feeling on this type of thing? I appreciate this could
>>> > > > well be abused, but right now it strikes me that there are lots of
>>> > > > situations where the designer doesnt have quite enough control over
>>> > > > the (presentation) logic without coding scala (altering the
>>> snippet)
>>> >
>>> > > > Thoughts?
>>> >
>>> > > > Cheers
>>> >
>>> > > > Tim
>>>
>>>
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Collaborative Task Management http://much4.us
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---