How to eval inside a Handlebars expression?

Viewed 1323

I have a backbone model returning something like this:

{
    language: "us",
    us: {
        title: "Gigs",
        subtitle: "Stay tune to my upcoming gigs"
    },
    br: {
        title: "Shows",
        subtitle: "Fique ligado na minha agenda"
    }
}

The language is being updated dynamically, so it will determinate which object I'm gonna print, using Handlebars. Usually I would do:

<h1>{{title}}</h1>
<h2>{{subtitle}}</h2>

But I need to do some kind of concat:

<h1>{{language.title}}</h1>
<h2>{{language.subtitle}}</h2>

Of course this will not work. That's my question: How can I make the expression to be dynamically concat?

So that if the language is "us", it calls:

<h1>{{us.language.title}}</h1>
<h2>{{us.language.subtitle}}</h2>

And if it's "br", it calls:

<h1>{{br.language.title}}</h1>
<h2>{{br.language.subtitle}}</h2>
3 Answers
Related