Skip to content

Commit

Permalink
A better template for exceptions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
twidi committed Nov 24, 2014
1 parent 9467116 commit b414d63
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 37 deletions.
57 changes: 29 additions & 28 deletions tmpl/exceptions.tmpl
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<?js
var data = obj;
var exceptions = obj;
var self = this;
?>
<?js if (data.description && data.type && data.type.names) { ?>
<dl>
<dt>
<div class="param-desc">
<?js= data.description ?>
</div>
</dt>
<dt>
<dl>
<dt>
Type
</dt>
<dd>
<?js= this.partial('type.tmpl', data.type.names) ?>
</dd>
</dl>
</dt>
</dl>
<?js } else { ?>
<div class="param-desc">
<?js if (data.description) { ?>
<?js= data.description ?>
<?js } else if (data.type && data.type.names) { ?>
<?js= this.partial('type.tmpl', data.type.names) ?>
<?js } ?>
</div>
<?js } ?>

<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">When</th>
</tr>
</thead>
<tbody>

<?js exceptions.forEach(function(exception) { ?>
<tr>
<td class="type">
<?js if (exception.type && exception.type.names) {?>
<?js= self.partial('type.tmpl', exception.type.names) ?>
<?js } ?>
</td>
<td class="description last">
<?js if (exception.description) { ?>
<?js= exceptions.description ?>
<?js } ?>
</td>
</tr>
<?js }); ?>

</tbody>
</table>
11 changes: 2 additions & 9 deletions tmpl/method.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,8 @@ var self = this;

<?js if (data.exceptions && exceptions.length) { ?>
<h5>Throws:</h5>
<?js if (exceptions.length > 1) { ?><ul><?js
exceptions.forEach(function(r) { ?>
<li><?js= self.partial('exceptions.tmpl', r) ?></li>
<?js });
?></ul><?js } else {
exceptions.forEach(function(r) { ?>
<?js= self.partial('exceptions.tmpl', r) ?>
<?js });
} } ?>
<?js= this.partial('exceptions.tmpl', exceptions) ?>
<?js }?>

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

0 comments on commit b414d63

Please sign in to comment.