I have an Image class:
class Image extends LongKeyedMapper[Image] with IdPK with Logger {
which overrides the HTML method:
override def toHtml =
<img src={"/gallery/image/%s/%s/%s/%s" format (slug.is, "fit", 100, 100)} />
and this works because of this:
def dispatch = {
LiftRules.dispatch.append {
case Req("gallery" :: "image" :: slug :: method :: width :: height :: Nil, _, _) => {
() => Image.stream(slug, method, width, height)
}
}
}
As you can see, this approach is not DRY , since you must define the URL (/ gallery / image) twice.
Is it possible to do it DRY? Can you get a path from LiftRules or something else?
Thanks in advance, Etam.
source
share