MIkCode
MIkCode

Reputation: 2845

play framework 2.1.1 get/set tags

I trying to use custom template tags but i cant make it work :( I'm using this link as reference tags doc

What i trying to achieve is to set some value (string) in one view and get it in another view

In the early version 1.2.4 look like you can use getter and setter this way...

Use #{get} and #{set} tags to share variables between the template and the decorator.

How can i get an set parameters in the view ??

Upvotes: 0

Views: 166

Answers (1)

mguillermin
mguillermin

Reputation: 4181

There is no get/set tags in Play 2. Every template is compiled to a function and the only way to pass a value from one template to another is by using parameters (= function arguments).

For instance, you can have a block.scala.html template where you define a title parameter :

@(title: String)
<div>
  <h2>@title</h2>
  ...
</div>

And you can just use it form another template using :

...
@block("My Title")
....

Upvotes: 1

Related Questions