Conditional Hits Template

Hi,

Re: hits item template… is it possible to break up the template? Render the standard template + render a small section based on a function.

Current solution is for the function to return the entire template. You have to return the template as 1 string, so it is not readable.

Ideal solution would be to have a standard template and a function that only alters a headline.

Template:

         `<div class="hit-header-block">
             <img class="hit-thumbnail" src="//logo.clearbit.com/hubspot.com?size=80">
             <p class="hit-title-secondary">{{ Vendor }}</p>
             <h5 class="hit-title-primary">{{ Card Name }}</h5>
           </div>
           <div class="hit-pricing-block-year">`
             // return if true
             `<h5 class="hit-price">{{ priceYear }}</h5>`
             // return if false
             `<h5 class="hit-price">{{ priceMonth }}</h5>
           </div>`

Current solution:

 templates: {
        item: function(item) {
          if(toggleOn) {
              return 'extremely long template string A'
            } else {
              return 'extremely long template string B'
            }
          }
        }

Hi @dom, could you have each of your template strings be a function and call those functions from the function in your template parameter? This way you would have several different functions based on your toggle instead of the whole string inside the if statement.