how to set a variable in a title?

Asked by marc

To set the title of a template you do:
#{set title:'Proile' /}

How can you do something like
#{set title:'Profile of ${user.login}' /}

Thank you in advance for the answer.

Question information

Language:
English Edit question
Status:
Solved
For:
play framework Edit question
Assignee:
No assignee Edit question
Solved by:
marc
Solved:
Last query:
Last reply:
Revision history for this message
Guillaume Bort (guillaume-bort) said :
#1

Hi,

You can use :

#{set title:'Profile of ' + user.login /}

or

#{set 'title'}
    Profile of ${user.login}
#{/set}

On Sun, Nov 16, 2008 at 2:54 PM, marc
<email address hidden>wrote:

> New question #51532 on play framework:
> https://answers.launchpad.net/play/+question/51532
>
> To set the title of a template you do:
> #{set title:'Proile' /}
>
> How can you do something like
> #{set title:'Profile of ${user.login}' /}
>
> Thank you in advance for the answer.
>
> --
> You received this question notification because you are a member of play
> framework developers, which is an answer contact for play framework.
>

Revision history for this message
marc (marc-ttux) said :
#2

Of course, thank you for your help.

Revision history for this message
snoopy3368 (snoopy3368+launchpad) said :
#3

This is a great example of using to variable to set the title, but how do you use i18n techniques? I.e. this example seems to be logical, but doesn't work:

#{set 'title'}
  &{'profile', user.login}
#{/set}

Revision history for this message
Guillaume Bort (guillaume-bort) said :
#4

It should work. What is the result ?

On 22 nov. 08, at 17:23, snoopy3368
<email address hidden> wrote:

> Question #51532 on play framework changed:
> https://answers.launchpad.net/play/+question/51532
>
> snoopy3368 posted a new comment:
> This is a great example of using to variable to set the title, but how
> do you use i18n techniques? I.e. this example seems to be logical,
> but
> doesn't work:
>
> #{set 'title'}
> &{'profile', user.login}
> #{/set}
>
> --
> You received this question notification because you are a member of
> play
> framework developers, which is an answer contact for play framework.

Revision history for this message
snoopy3368 (snoopy3368+launchpad) said :
#5

The browser title bar shows nothing. I.e. put &{....} and it stops working. If you reveal the source the source is empty for <title></title> I'm using play! 1.0-stable3-r197.

Revision history for this message
Guillaume Bort (guillaume-bort) said :
#6

Have you correctly defined the application.langs property ?

On 22 nov. 08, at 21:46, snoopy3368
<email address hidden> wrote:

> Question #51532 on play framework changed:
> https://answers.launchpad.net/play/+question/51532
>
> snoopy3368 posted a new comment:
> The browser title bar shows nothing. I.e. put &{....} and it stops
> working. If you reveal the source the source is empty for
> <title></title> I'm using play! 1.0-stable3-r197.
>
> --
> You received this question notification because you are a member of
> play
> framework developers, which is an answer contact for play framework.

Revision history for this message
snoopy3368 (snoopy3368+launchpad) said :
#7

Yes. I've changed the example to include a <h1> element with the exact same property to be translated and it works properly.

#{set 'title'}
  &{'profile', user.login} <!-- this does not work -->
#{/set}

<h1>&{'profile', user.login}</h1> <!-- this works -->

Revision history for this message
marc (marc-ttux) said :
#8

#{set 'title'}
  &{'profile', user.login} <!-- this does not work -->
#{/set}

I am doing like this and that works:
#{set 'title'}
  &{'profile'} of ${user.login}
#{/set}

You can't have the variable inside the &{} because that's what it's going to look for in the properties file.

Revision history for this message
Guillaume Bort (guillaume-bort) said :
#9

#{set 'title'}
 &{'profile', user.login}
#{/set}

should work. With something like

profile=Profile of %s

in a conf/messages file

It works for me. If you can't make it work, can you send me a sample
application ?
Thanks.

On Mon, Nov 24, 2008 at 8:18 PM, marc
<email address hidden>wrote:

> Question #51532 on play framework changed:
> https://answers.launchpad.net/play/+question/51532
>
> marc posted a new comment:
> #{set 'title'}
> &{'profile', user.login} <!-- this does not work -->
> #{/set}
>
> I am doing like this and that works:
> #{set 'title'}
> &{'profile'} of ${user.login}
> #{/set}
>
> You can't have the variable inside the &{} because that's what it's
> going to look for in the properties file.
>
> You received this question notification because you are a member of play
> framework developers, which is an answer contact for play framework.
>