Skip to content

Commit fc72c43

Browse files
committed
A better template for exceptions
Instead of a non-styled dd/dt template, called for each exception, call one template with a table for all exception, using same styles as params: type and description
1 parent 47f3ec1 commit fc72c43

File tree

2 files changed

+31
-37
lines changed

2 files changed

+31
-37
lines changed

tmpl/exceptions.tmpl

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
<?js
2-
var data = obj;
2+
var exceptions = obj;
3+
var self = this;
34
?>
4-
<?js if (data.description && data.type && data.type.names) { ?>
5-
<dl>
6-
<dt>
7-
<div class="param-desc">
8-
<?js= data.description ?>
9-
</div>
10-
</dt>
11-
<dt>
12-
<dl>
13-
<dt>
14-
Type
15-
</dt>
16-
<dd>
17-
<?js= this.partial('type.tmpl', data.type.names) ?>
18-
</dd>
19-
</dl>
20-
</dt>
21-
</dl>
22-
<?js } else { ?>
23-
<div class="param-desc">
24-
<?js if (data.description) { ?>
25-
<?js= data.description ?>
26-
<?js } else if (data.type && data.type.names) { ?>
27-
<?js= this.partial('type.tmpl', data.type.names) ?>
28-
<?js } ?>
29-
</div>
30-
<?js } ?>
5+
6+
<table class="params">
7+
<thead>
8+
<tr>
9+
<th>Type</th>
10+
<th class="last">When</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
15+
<?js exceptions.forEach(function(exception) { ?>
16+
<tr>
17+
<td class="type">
18+
<?js if (exception.type && exception.type.names) {?>
19+
<?js= self.partial('type.tmpl', exception.type.names) ?>
20+
<?js } ?>
21+
</td>
22+
<td class="description last">
23+
<?js if (exception.description) { ?>
24+
<?js= exception.description ?>
25+
<?js } ?>
26+
</td>
27+
</tr>
28+
<?js }); ?>
29+
30+
</tbody>
31+
</table>

tmpl/method.tmpl

+2-9
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,8 @@ var self = this;
7373

7474
<?js if (data.exceptions && exceptions.length) { ?>
7575
<h5>Throws:</h5>
76-
<?js if (exceptions.length > 1) { ?><ul><?js
77-
exceptions.forEach(function(r) { ?>
78-
<li><?js= self.partial('exceptions.tmpl', r) ?></li>
79-
<?js });
80-
?></ul><?js } else {
81-
exceptions.forEach(function(r) { ?>
82-
<?js= self.partial('exceptions.tmpl', r) ?>
83-
<?js });
84-
} } ?>
76+
<?js= this.partial('exceptions.tmpl', exceptions) ?>
77+
<?js }?>
8578

8679
<?js if (data.returns && returns.length) { ?>
8780
<?js if (returns.length > 1) { ?><h5>Returns:</h5><?js } ?>

0 commit comments

Comments
 (0)