歡迎來到 KnowBe4 知識庫!
有什麼能幫忙的嗎?
按主題瀏覽
需要更多協助?
Recent updates
<% } %>-
<% articles.forEach(function(article) { %>
<% /* Both lookups can miss, and the category one has to be guarded by
the section it reads. sections and categories are fetched as
separate API calls from articles, and all three are
permission-filtered per viewer, so an article can legitimately
arrive whose section is not in the list -- and section['category_id']
on a null section throws. A throw here is not contained: the whole
recent-updates block fails to render, because a micro-template has
no error boundary around a single iteration. A missing category just
drops the badge, which the `if (category)` below already handles. */ %>
<% var section = sections.filter(function(section) { return section.id === article['section_id']; })[0] || null; %>
<% var category = section ? (categories.filter(function(category) { return category.id === section['category_id']; })[0] || null) : null; %>
-
<% if (category) { %>
<% var categoryPosition = category.position; %>
<% var badgeVariant = (categoryPosition >= 3 && categoryPosition < 6) ? categoryPosition - 2 : 0; %>
<%= category.name %>
<% } %>
<%= article.title %>
View article
<% }) %>