Kuma: KumaScript - Calling VersionTimeline template from IFSummary template is not working



Wiki pages
6 years ago
5 years ago


(Reporter: sheppy, Unassigned)





6 years ago
Our IFSummary template is used in every XPCOM interface article to generate the heading at the top that provides an overview of what the interface is, when it was introduced, etc.

It calls out to the VersionTimeline template, which generates, using CSS, a neat timeline indicating when it was introduced, became obsolete, last changed, etc. Calling VersionTimeline directly from a page (see https://developer-new.mozilla.org/en-US/docs/User:Sheppy/TemplateTests for example) works fine.

Calling it from within IFSummary does nothing; indeed, the VersionTimeline template never executes, even though an HTML comment I inject right before calling it does appear in the page output.

For example, go to page: https://developer-new.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIMemoryReporter and search for "timeline" in the page source; this will show you the comment that IFSummary inserts immediately before trying to call VersionTimeline. This is done at line 75 of IFSummary.

If you look at the very first line of VersionTimeline, it begins by injecting another comment listing its input parameters.

When called from IFSummary, that line never appears.

But it does appear when VersionTimeline is called directly, as on the TemplateTests page.

So something is afoot here.

This is urgent to fix before ship. Indeed, if there's a problem with calling templates from each other, it needs to be fixed ASAP because this will hamper work on getting templates converted.
There was a problem in the IFSummary template. I found this code:

if ($5) {
  %> <!-- timeline: <%=$5%>, <%=$3%>, <%=$7%>, <%=$6%> --> <%
  template("VersionTimeline", [$5, $3, $7, $6]);

I fixed it like so:

<% if ($5) { %>
  <%- template("VersionTimeline", [$5, $3, $7, $6]) %>
<% } %>

The template() call was not made in an output section (ie. outside a <% %> JS block) and wasn't wrapped in <%- %>, so the return value never made it into the output stream.
Last Resolved: 6 years ago
Resolution: --- → FIXED


6 years ago
Version: Kuma → unspecified


6 years ago
Component: Website → Landing pages
Product: Mozilla Developer Network → Mozilla Developer Network
You need to log in before you can comment on or make changes to this bug.