Subpackages within snippet for Snippet Class resolution

71 views
Skip to first unread message

RyanDS

unread,
Jun 24, 2011, 6:15:23 PM6/24/11
to Lift
Firstly thank you for all the great work in providing lift to the
community, absolutely love developing with it.

I am almost certainly missing something but I cannot figure out what
it is, is there a reason why during snippet class resolution lift
cleans off anything but the final class and method. I have played
around with LiftRules.snippetNamesToSearch and have a god awful hack
in to search sub packages of xxx.snippet but would like to simply add
the package to the lift class in the template. My feeling would have
been that

<span class="lift:subPack.HelloWorld.hello">Your snippet result here</
span>

would have resolved to the xxx.snippet.subpack.HelloWorld class and
called the hello method, but currently seems to find the class
xxx.snippet.HelloWorld. I have not found anything in this group or in
any of the documentation or wikis that give an indication how to
change that beaviour apart from the LiftRules.snippetNamesToSearch, at
which point any package name has been removed and just the class name
is provided.

It strikes me that either there is good reason for not allowing the
package to be included or that I am plain missing an easy way of doing
this.

Much appreciated

David Pollak

unread,
Jun 27, 2011, 2:19:26 PM6/27/11
to lif...@googlegroups.com

The issue has never come up that I recall.

You're welcome to open a ticket (http://ticket.liftweb.net you must be a watcher of the LiftWeb space on Assembla).  If you have an explicit use case, please add it to this thread.  Otherwise, we'll treat it as a feature request that we track, but don't necessarily prioritize up.

Thanks,

David
 

Much appreciated

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




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

Francois Armand

unread,
Jun 27, 2011, 3:23:58 PM6/27/11
to lif...@googlegroups.com
Le 25/06/2011 00:15, RyanDS a �crit :
[..]

>
> I am almost certainly missing something but I cannot figure out what
> it is, is there a reason why during snippet class resolution lift
> cleans off anything but the final class and method. I have played
> around with LiftRules.snippetNamesToSearch and have a god awful hack
> in to search sub packages of xxx.snippet but would like to simply add
> the package to the lift class in the template. My feeling would have
> been that
>
> <span class="lift:subPack.HelloWorld.hello">Your snippet result here</
> span>
>
> would have resolved to the xxx.snippet.subpack.HelloWorld class and
> called the hello method, but currently seems to find the class
> xxx.snippet.HelloWorld. I have not found anything in this group or in
> any of the documentation or wikis that give an indication how to
> change that beaviour apart from the LiftRules.snippetNamesToSearch, at
> which point any package name has been removed and just the class name
> is provided.
>
> It strikes me that either there is good reason for not allowing the
> package to be included or that I am plain missing an easy way of doing
> this.


Any hint or way to do that would be much appreciate (or I second the
feature request :)

My use case is that I tend to organize big main pages into small
components, some being transverse to several pages, some specific to a
page (for example, an ajax form which appears on some condition is a
good candidate to be externalize in its own snippet).

As we are starting to have a lot of main pages, and so I would like to
organize snippets in a tree like:

/snippets
|- commons
| `> here should go common snippets
|- page1 [a 'main' page]
| |- snippets specific to page1
| `- etc
etc


Thanks !


--
Francois Armand
http://fanf42.blogspot.com

RyanDS

unread,
Jun 28, 2011, 10:45:48 AM6/28/11
to Lift
Thanks for the response David, similar to Francois it is mostly for
organizational purposes. We have a user interface that allows users
to dynamically generate and modify forms, adding numerous sections of
different types, re-arranging them, modifying content etc. We are
using separate templates for each form section type and we have a
number of different dynamic forms, consequently we are building up a
large number of snippets that are becoming unwieldy. As these are
templates loaded within the a larger top level page I cannot use the
trick of using the URL path to access sub packages without re-
arranging all the site into little folders of one page each, which
would feel a little artificial.

I will raise a ticket and add the use case.

Again thanks for all the work you have put into Lift, it is much
appreciated

Ryan

Diego Medina

unread,
Jun 29, 2011, 10:30:22 AM6/29/11
to lif...@googlegroups.com
Maybe too simple of a question but, do you need this feature because
otherwise you have class name collision ? (maybe you already know this
but:) you could have your scala files in sub-directories but still
have your class name be just one level under snippet.

Sorry if you already knew this.

Diego

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

--
Diego Medina
Web Developer
http://www.fmpwizard.com

RyanDS

unread,
Jun 29, 2011, 11:11:43 AM6/29/11
to Lift
I had not thought of that, thanks for the idea. While it would
provide a partial solution, my feeling is it has a couple of
drawbacks, as you say class name collision is one and secondly for
large projects the one to one mapping from package structure to
directory structure is helpful for those not familiar with the code
base.

Ryan
> > For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en.
Reply all
Reply to author
Forward
0 new messages