Search code examples
scalalift

single "*" wildcard in Lift SiteMap Menu entry


It looks as though the Lift SiteMap DSL supports both "*" and "**" as wildcards. Apparently "**" is used only at the end of a path, when you want to match all paths that start with some prefix. But I don't understand how "*" is meant to be used. I had hoped it would act as a wildcard for one path component in a path. So something like:

    Menu("Category Home Pages") / "category" / * / "home"

would match:

    /category/alpha/home
    /category/beta/home
    /category/gamma/home
    etc.

But this doesn't work for me. (I get a 404 even though the path exists in the filesystem.) If this is not supposed to be the function of "*", could someone please enlighten me? I've only been able to find documentation for "**".


Solution

  • * will matched a single level path, and ** will match any level of path.

    For example, as you say,

    Menu("Category Home Pages") / "category" / * / "home"
    

    will match

    /category/alpha/home
    /category/beta/home
    /category/gamma/home
    etc.
    

    But you still need HTML template called home.html in webapp/category/alpha/ or other matching templates.

    If you don't have corresponding HTML templates, Lift will response a 404 error.