Watcher with external html template

I have a fairly basic question. I have a watcher, I load a html template using a http input. I want to use this template (which contains mustache syntax) in my action. Is it possible? At the moment I just get the html without the mustache functionality applied. Using Elasticsearch 5.6.

This is how the email action looks like below. My idea was that the params option would enable me to use {{#hits}}... in my external template but it didn't work.

"body": {
      "html": {
        "source": "{{ctx.payload.template._value}}",
        "lang": "mustache",
        "params": {
          "hits": "{{ctx.payload.query.hits.hits}}"
        }
      }
    }

But yea, feels like a step missing :slight_smile:

Hi, I'm not sure if this is possible, since the mustache values will have to "unfold" twice. params isn't a valid option for email actions. Have you tried just doing:

"body": {
      "html": "{{ctx.payload.template._value}}"
    }
}

and make sure that the external template ctx.payload.template._value has mustache in it? For example, maybe the value of the external template is:

Hits over {{ctx.payload.query.hits.hits}}

I'm not certain this will work, since it still has to compile mustache twice. But worth a shot.

Yea that's what i tried the first time and the reason i tried the source and param thing. Sadly didn't work.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.