forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturns.tmpl
More file actions
86 lines (77 loc) · 2.62 KB
/
returns.tmpl
File metadata and controls
86 lines (77 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?js
var returns = obj;
var parentReturn = null;
var hasName = false;
var hasType = false;
returns.forEach(function (ret, i) {
if (ret && (ret.description || ret.name)) {
ret.description = ret.description.toString().replace(/<\/?p>/g, '');
var isNamed = ret.name ? true : false;
var name = ret.name || ret.description;
var startSpacePos = name.indexOf(' ');
if (parentReturn !== null && name.indexOf(parentReturn.name + '.') === 0) {
ret.name = isNamed ? name.substr(parentReturn.name.length + 1) : name.substr(parentReturn.name.length + 1, startSpacePos - (parentReturn.name.length + 1));
if (!isNamed) {
ret.description = ret.description.substr(startSpacePos + 1);
}
ret.isSubReturns = true;
parentReturn.subReturns = parentReturn.subReturns || [];
parentReturn.subReturns.push(ret);
returns[i] = null;
} else if (returns.length > 1 || ret.isSubReturns) {
if (!isNamed) {
ret.name = ret.description.substr(0, startSpacePos !== -1 ? startSpacePos : ret.description.length);
ret.description = startSpacePos !== -1 ? ret.description.substr(startSpacePos + 1) : '';
}
parentReturn = ret;
}
}
if (ret.name) {
hasName = true;
}
if (ret.type) {
hasType = true;
}
});
?>
<?js if (hasType) { ?>
<table class="params">
<thead>
<tr>
<?js if (hasName) { ?><th>Name</th><?js } ?>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<?js
var self = this;
returns.forEach(function(ret) {
if (!ret) {
return false;
}
?>
<tr>
<?js if (ret.name) { ?><td class="name"><code><?js= ret.name ?></code></td><?js } ?>
<td class="type">
<?js
if (ret.type && ret.type.names) {
ret.type.names.forEach(function(name, i) { ?>
<?js= self.linkto(name, self.htmlsafe(name)) ?>
<?js if (i < ret.type.names.length-1) { ?> | <?js } ?>
<?js });
}
?>
</td>
<td class="description last"><?js= ret.description ?><?js if (ret.subReturns) { ?>
<?js= self.partial('returns.tmpl', ret.subReturns) ?>
<?js } ?></td>
</tr>
<?js }); ?>
</tbody>
</table>
<?js } else { ?>
<?js if (returns[0].description) { ?>
<?js= returns[0].description ?>
<?js } ?>
<?js } ?>