Partials in Handlebars

PHOTO EMBED

Thu Sep 22 2022 23:03:33 GMT+0000 (UTC)

Saved by @zaccamp #javascript #handlebars

// Homepage.Handlebars
<ol class="post-list">
  {{#each posts as |post|}}
  <li>
    {{> post-info post}}
  </li>
  {{/each}}
</ol>
---
//Post-info.Handlebars (partial)
<article class='post'>
  <div class='title'>
    <a href='{{post_url}}' target='_blank'>{{title}}</a>
    <span>({{post_url}})</span>
  </div>
  <div class='meta'>
    {{vote_count}}
    point(s) by
    {{user.username}}
    on
    {{created_at}}
    |
    <a href='/post/{{id}}'>{{comments.length}} comment(s)</a>
  </div>
</article>
content_copyCOPY