Friday 15 May 2015

groovy - In Play Framework 1.2.x, how to use a render arg value in a path expression? -



groovy - In Play Framework 1.2.x, how to use a render arg value in a path expression? -

let's have renderarg named xyz. in groovy template, what's syntax using value of renderarg in path expression?

for example:

href="@@{'/public/stylesheets/whatever/${xyz}.css'}"

the above fails template compilation error (which expected, really). how can utilize value of render arg within path string?

i'll need utilize arg in other path expressions (not css file reference).

you cannot directly, there 1 workaround:

first should have defined route root of application, instance:

get / application.index

next can utilize in way:

href="@@{application.index}public/stylesheets/whatever/${xyz}.css"

if repeat construction above often, can utilize custom tag, so:

add file /app/views/tags/customlink.html(customlink name of tag, can utilize one),

fill content:

@@{application.index}public/stylesheet/whatever/${_key}.css

you can utilize in way:

href="#{customlink key:'xyz' /}"

more custom tags can read here

groovy playframework-1.x

No comments:

Post a Comment