apinode
Version:
An API server that can greatly reduce the work needed to implment API services. It can also cooperate with other API node to make it a mesh of services.
57 lines (54 loc) • 1.48 kB
HTML
<%
var word = _params.word,
tableStyle = _params.tableStyle,
rows = _params.rows;
%>
<%if( Object.prototype.toString.call(rows) === '[object Array]' ) {%>
<table class="table <%=tableStyle.join(' ')%>">
<thead>
<tr>
<th style="width:150px"><%=word.parameter || "Parameter"%></th>
<th style="width:90px; text-align: center;"><%=word.required || "Required"%></th>
<th style="width:130px; text-align: center;"><%=word.default || "Default"%></th>
<th style=""><%=word.description || "Description"%></th>
</tr>
</thead>
<tbody>
<% if(rows.length > 0){
rows.forEach(function(ele){
tr(0, ele);
});
} else {
%>
<tr>
<td style="text-align: center;">-</td>
<td style="text-align: center;">-</td>
<td style="text-align: center;">-</td>
<td style="text-align: center;">-</td>
</tr>
<% }%>
</tbody>
</table>
<%} else {%>
Is not array.
<%}%>
<%function tr(deep, params){%>
<tr>
<td><%=getBlockquote(deep) + params.key + getTypeMark(params.type)%></td>
<td><%=params.required ? 'v' : ''%></td>
<td style="text-align: center;"><%=params.default%></td>
<td><span class='markdown'><%=params.descTx%></span></td>
</tr>
<%if(params.more){
params.more.forEach(function(ele){
tr(deep+1, ele);
});
}}%>
<%
function getBlockquote(deep) {
return new Array(deep*6).fill(" ").join("") + (deep > 0 ? "." : "");
}
function getTypeMark(type) {
return type == 'array' ? ' [ ]' : '';
}
%>