Impossible to access helper inside {{#markdown}}?

Hello,
I’ve tried the following, where entry is my cursor, and i’m trying to retrieve data from it.

      {{#markdown}}{{entry.fields.Text}}{{/markdown}}

But it gives no results inside the markdown.
When used outside, my helper is showing data, but inside {{#markdown}} returns undefined.

You can call a newly defined helper inside a marker, but not an existing one.

{{#markdown}}
{{#let entry = data}}
{{entry}}  <!-- "data is produced here" -->
{{/let}}
{{/markdown}}

In this case above {{data}} will show up.

{{#let entry = data}} 
{{#markdown}}
{{entry}} <!-- undefined -->
{{/markdown}}
{{/let}}

But in this case the data will not be retrieved successfully.

I’m using kadira:blaze-layout, kadira:flow-router, markdown
My render is done like this:

  FlowRouter.route('/temp', {
    name: 'temp',
    action(params) {
      BlazeLayout.render('temp', {params: params})
    }
  })

Hard to give a clear answer but it could be due to entry or the array where entry is contained does not exist.

Can you provide a bit more context? Which packages do you have installed and can you please add at least the Template html and js code, reduced to the parts that are relared to the issue?

The data of entry exists and is retrieved in the template. Here is some of the context:

work is an cursor object containirg a field call Entries.
Entries is an array of ids. Each id is stored in entryid.
The function id(entryid) finds the corresponding object and stores it in the entry cursor object.
The entry cursor object is called on the Text field, and is logged:
-once inside the markdown spacebar
-once outside


  {{#let work=getwork}}
   {{#each entryid in work.fields.Entries}} 
    {{#let entry = (id entryid) }} 
    {{log "outside_markdown" entry.fields.Text}}
    {{#markdown}}
    {{log "inside_markdown" entry.fields.Text}}
    {{/markdown}}
    {{/let}}
   {{/each}}
  {{/let}}

Output in console:

helpers.js:20 outside_markdown Aleph is a monumental installation that happened once in Paris, under the beautiful dome of Palais Malaquais before its renovation.
helpers.js:17 inside_markdown

As you can see, the data doesnt appear on the inside_markdown label i’ve put to identify the problem, but is correctly displayed outside.

As jamgold taught me, you can solve the problem by creating a subtemplate where you insert your markdown.


  {{#let work=getwork}}
   {{#each entryid in work.fields.Entries}} 
    {{#let entry = (id entryid) }} 
      {{>entry_template entry=entry}}
    {{/let}}
   {{/each}}
  {{/let}}
<template name=entry_template>
{{#markdown}}{{{entry.fields.Text}}}{{/markdown}}
</template>
1 Like