user1995781
user1995781

Reputation: 19463

Dust.js dynamic keys & sections

I am new to Dust.js. Is it possible for the latest version of dust.js to display value via dynamic keys or sections? If possible please show me how. If not possible, then how can we work on such condition using javascript with dust.js?

Thank you.

Upvotes: 3

Views: 510

Answers (1)

Simon
Simon

Reputation: 1754

If you use LinkedIn's fork of dust then, yes, you can use dynamic variables. For the following context:

{
    variable: 'one',
    object: {
        one: 'first variable',
        two: 'second variable'
    }
}

You can do the following in your template:

{object[variable]}

Which will print 'first variable'.

Upvotes: 4

Related Questions