javascript - Injecting Carbon in Handlebars Template -
i have handlebars template renders articles on site fetching data through api. api returning timestamp i'd convert human readable format. format timestamp through js wondering whether inject carbon, diffforhumans()
specific, on fly.
<script id="article-template" type="text/x-handlebars-template"> <div class="post-item"> <div class="post-item__thumb"> <img class="post-item__thumb__img" src="@{{ thumbnail_image }}" alt="@{{ title }}"/> </div> <div class="post-item__content"> <a class="post-item__title" href="@{{ url }}">@{{ title }}</a> <p class="post-item__meta"> <a href="#">@{{ author }}</a> on @{{ published_at }} </p> <p class="post-item__teaser">@{{ excerpt }}</p> <a class="post-item__read-full" href="@{{ url }}">read full article</a> </div> </div> </script>
would possible go doing this?
<p class="post-item__meta"> <a href="#">@{{ author }}</a> on @{{ published_at }}{{ diffforhumans() }} </p>
Comments
Post a Comment