Reputation: 819
I am using Play Framework 1.2.5. What is the difference between:
@{Application.render()}
and
@Application.render()
The first one is preferably used in the form action whereas the second one may be used for an anchor template. Both of them will be generating a URL, hence not able to understand which for the first one I need a {}
surrounding braces.
Please let me know about this.
Thanks,
Upvotes: 0
Views: 173
Reputation: 396
@{}
is a short cut to generate a relative url based on a reverse route (Controller.method -> URL)
@@{}
gives you the absolute URL
#{}
refer to tags. There just so happens to be an #a
tag and you can do
#{a @Application.logout()}Disconnect#{/a}
because within the tag, you're actually passing the ActionDefinition when doing @Application.logout()
, not the URL.
See http://www.playframework.org/documentation/1.2.5/tags
Upvotes: 1
Reputation: 2065
As far as I know, you need the curly braces when you use this in a template, for instance:
<form action="@{Application.post}">
.
I just tried without the curly braces and that resulted in the exact string (@Application.render) and not an URL.
My code in the template:
@Application.index()<br />
@{Application.index()}<br />
Results in the following HTML in my browser:
@Application.index()<br />
/<br />
Upvotes: 0