# Template rendering using mustache

**URL:** <https://discuss.elastic.co/t/template-rendering-using-mustache/51022>\
**Category:** Elasticsearch\
**Created:** [May 26, 2016, 6:50am UTC](https://discuss.elastic.co/t/template-rendering-using-mustache/51022 "2016-05-26T06:50:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Lund\_Askoe](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Martin\_Lund\_Askoe](https://discuss.elastic.co/u/Martin_Lund_Askoe)\
**Post date:** [May 26, 2016, 6:50am UTC](https://discuss.elastic.co/t/template-rendering-using-mustache/51022/1 "2016-05-26T06:50:22Z")

</div>

I've been trying to create a template, but I am having some trouble with the mustache rendering.

On the page: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html), you mention how to use a pre-registered template, that is what I wanted to do. It doesn't really work and the output is very minimal, such as "Unexpected ']'".

I thought I'd start with one of you examples and then call the REST endpoint /\_render/template  
So this one:

```
{
  "inline": {
    "query": {
      "terms": {
        "status": [
          "{{#status}}",
          "{{.}}",
          "{{/status}}"
        ]
      }
    }
  },
  "params": {
    "status": ["pending", "published"]
  }
}

```

Have you tried rendering this?

It is supposed to give this output:

```
{
  "template_output": {
    "query": {
      "terms": {
        "status": [ 
          "pending",
          "published"
        ]
      }
    }
  }
}

```

but I get:

```
{
  "template_output": {
    "query": {
      "terms": {
        "status": [
          "",
          "pending",
          "",
          "published",
          ""
        ]
      }
    }
  }
}

```

Now if my status would never be "", then this query would work, but it would not be what I expected?  
I am running Elastic Search 2.1.0.

This question was asked and dismissed in topic: [Search template creates unnecessary empty strings in arrays](https://discuss.elastic.co/t/search-template-creates-unnecessary-empty-strings-in-arrays/25353)

I am not showing my own example.  
I am using the examples from your own reference guide, so that I won't confuse the issue with my own failed attempts.

Kind regards, Martin.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:48pm UTC](https://discuss.elastic.co/t/template-rendering-using-mustache/51022/2 "2017-07-05T22:48:55Z")

</div>


