Accessing data context from inside {{#with}}


#1

I have a template which I use to display a post.
I’m using spacebars {{#with}} to determine whether the data context provides a picture or not:

<div class="title">{{title}}</div>
<div class="subtitle">{{subtitle}}</div>

{{#with image}}
<a href="{{pathFor 'post'}}"><img src="{{this}}" alt="{{../title}}"></a> <!-- TODO this does not work -->
{{/with}}

<dic class="text">{{text}}</div>

I can’t figure out how to access the data context of the template from within {{#with}} .

For pathFor I need the post _id (which I can access outside of {{#with}} ).
The use of {{../title}} also does not work.

Any idea what I’m doing wrong?


#2

I also always have problems with {{../}}, I usually do:

{{#if image}}
  <a href="{{pathFor 'post'}}"><img src="{{image}}" alt="{{title}}"></a>
{{/if}}

#3
{{#with _id=_id title=title image=image}}
  <a href="{{pathFor 'post'}}"><img src="{{image}}" alt="{{title}}"></a>
{{/with}}