user1911292
user1911292

Reputation: 23

Pass current context to dustjs helper

I'm using a partial helper as;

{<subTemplate}
 {type}
 {minute}
 {count}
{/subTemplate}

{@partial type=type minute=minute count=count}
  {+sub_template/}
{/partial}

but as you can see for any field I want to use in my subTemplate, I need to add to the partial declaration. I tried

{@partial record=.}
  {+sub_template/}
{/partial}

but doesn't seem to work.

Any ideas?

Upvotes: 2

Views: 1141

Answers (1)

Chad Carisch
Chad Carisch

Reputation: 2472

The documentation does not state that the base template ever gets access to the the Context. It appears that it is intended for html formatting only. Not for data. See Dust Blocks and inline partials for more info.

You could set a global context variable for use in the base template to get around this limitation. This is also described in the dust tutorial at Setting your own context.

Upvotes: 1

Related Questions