Custom helpers

Modified on Mon, 16 Nov, 2020 at 11:13 AM

renderFromApi

Block helper. Makes an API call and on complete, whether success or failure, it executes the given block of the code. The parameters are accepted as same as the jQuery ajax paramters except the functions. Please refer jQuery ajax call here

Params

  • url {String | Number}

  • Method {String}

Example:


{{#renderFromApi url="/support/v2/solutions/articles/popular" method="GET"}}

    <section id="solutions-banner">

      <h2>Trending Topics</h2>

      {{#this}}

        <a href="{{#if external_url}}{{external_url}}{{else}}/support/solutions/articles/{{id}}{{/if}}" class="card solution-card">

           <div class="elem-inline-mid">

             <h3>{{title}}</h3>

             <p>{{description}}</p>

         </div>

         </a>

      {{/this}}

    </section>

  {{/renderFromApi}}

avatar

Accepts params as normal image tag, one more extra param - name. Check for the profile picture for the user in the given url. If unavailable, then will render the first letter of the given name with the provided random image.

Example:


{{avatar name=user_info.full_name url=user_info.profile_pic class="user-profile-pic"}}

 
Pagination

The pagination helper is a block helper. The params needed for the pagination helpers are  - 

 - list

 - id

 - class (optional)

 - perPage (optional) : determines the number of items shown in a page

 - page (optional) : current page no

 - params (optional)

 - paginationContainer (the nav container id where the pagination links should be rendered)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article