Skip to content
Browse files

Dropped print() calls in template in favor of templating engine.

  • Loading branch information...
1 parent 84b4448 commit cd3abea318e334281c399d4b4f7bc49e34905f9c @rafalwrzeszcz rafalwrzeszcz committed Jan 4, 2012
View
187 templates/default/tmpl/container.tmpl
@@ -6,199 +6,130 @@
<section>
<header>
- <h2><?js
- if (doc.ancestors && doc.ancestors.length) {
- print('<span class="ancestors">');
- print( doc.ancestors.join('') );
- print('</span>' + doc.name);
- }
- else {
- print(doc.name)
- }
-
- if (doc.variation) {
- print('<sup class="variation">'+doc.variation+'</sup>');
- }
-
- ?></h2>
- <?js
- if (doc.classdesc) {
- print('<p class="class-description">'+doc.classdesc+'</p>');
- }
- ?>
+ <h2><?js if (doc.ancestors && doc.ancestors.length) { ?>
+ <span class="ancestors"><?js= doc.ancestors.join('') ?></span>
+ <?js } ?>
+ <?js= doc.name ?>
+ <?js if (doc.variation) { ?>
+ <sup class="variation"><?js= doc.variation ?></sup>
+ <?js } ?></h2>
+ <?js if (doc.classdesc) { ?>
+ <p class="class-description"><?js= doc.classdesc ?></p>
+ <?js } ?>
</header>
<article>
<div class="container-overview">
- <?js
- if (doc.kind === 'module' && doc.module) {
- print(self.partial('method.tmpl', doc.module));
- }
+ <?js if (doc.kind === 'module' && doc.module) { ?>
+ <?js= self.partial('method.tmpl', doc.module) ?>
+ <?js } ?>
- if (doc.kind === 'class') {
- print(self.partial('method.tmpl', doc));
- }
- else {
- if (doc.description) {
- print('<p class="description">' + doc.description + '</p>');
- }
-
- print(self.partial('details.tmpl', doc));
-
- if (doc.examples && doc.examples.length) {
- print('<h3>Example' + (doc.examples.length > 1? 's':'') + '</h3>');
- print( self.partial('examples.tmpl', doc.examples) );
- }
- }
- ?>
+ <?js if (doc.kind === 'class') { ?>
+ <?js= self.partial('method.tmpl', doc) ?>
+ <?js } else { ?>
+ <?js if (doc.description) { ?>
+ <p class="description"><?js= doc.description ?></p>
+ <?js } ?>
+
+ <?js= self.partial('details.tmpl', doc) ?>
+
+ <?js if (doc.examples && doc.examples.length) { ?>
+ <h3>Example<?js= doc.examples.length > 1? 's':'' ?></h3>
+ <?js= self.partial('examples.tmpl', doc.examples) ?>
+ <?js } ?>
+ <?js } ?>
</div>
- <?js
- if (doc.augments && doc.augments.length) {
- ?>
+ <?js if (doc.augments && doc.augments.length) { ?>
<h3 class="subsection-title">Extends</h3>
- <ul><?js
- doc.augments.forEach(function(a) {
- ?>
+ <ul><?js doc.augments.forEach(function(a) { ?>
<li><?js= self.linkto(a, a) ?></li>
- <?js
- });
- ?></ul>
- <?js
- }
- ?>
+ <?js }); ?></ul>
+ <?js } ?>
- <?js
- if (doc.mixes && doc.mixes.length) {
- ?>
+ <?js if (doc.mixes && doc.mixes.length) { ?>
<h3 class="subsection-title">Mixes In</h3>
- <ul><?js
- doc.mixes.forEach(function(a) {
- ?>
+ <ul><?js doc.mixes.forEach(function(a) { ?>
<li><?js= self.linkto(a, a) ?></li>
- <?js
- });
- ?></ul>
- <?js
- }
- ?>
+ <?js }); ?></ul>
+ <?js } ?>
- <?js
- if (doc.requires && doc.requires.length) {
- ?>
+ <?js if (doc.requires && doc.requires.length) { ?>
<h3 class="subsection-title">Requires</h3>
- <ul><?js
- doc.requires.forEach(function(r) {
- ?>
+ <ul><?js doc.requires.forEach(function(r) { ?>
<li><?js= self.linkto(r, r) ?></li>
- <?js
- });
- ?></ul>
- <?js
- }
- ?>
+ <?js }); ?></ul>
+ <?js } ?>
<?js
var classes = self.find({kind: 'class', memberof: doc.longname});
if (doc.kind !== 'globalobj' && classes && classes.length) {
?>
-
<h3 class="subsection-title">Classes</h3>
- <dl><?js
- classes.forEach(function(c) {
- ?>
+ <dl><?js classes.forEach(function(c) { ?>
<dt><?js= self.linkto(c.longname, c.name) ?></dt>
- <dd><?js if (c.summary) print(c.summary); ?></dd>
- <?js
- });
- ?></dl>
-
+ <dd><?js if (c.summary) { ?><?js= c.summary ?><?js } ?></dd>
+ <?js }); ?></dl>
<?js } ?>
<?js
var namespaces = self.find({kind: 'namespace', memberof: doc.longname});
if (doc.kind !== 'globalobj' && namespaces && namespaces.length) {
?>
-
<h3 class="subsection-title">Namespaces</h3>
- <dl><?js
- namespaces.forEach(function(n) {
- ?>
+ <dl><?js namespaces.forEach(function(n) { ?>
<dt><a href="namespaces.html#<?js= n.longname ?>"><?js= self.linkto(n.longname, n.name) ?></a></dt>
- <dd><?js if (n.summary) print(n.summary); ?></dd>
- <?js
- });
- ?></dl>
-
+ <dd><?js if (n.summary) { ?><?js= n.summary ?><?js } ?></dd>
+ <?js }); ?></dl>
<?js } ?>
<?js
- var members = self.find({kind: 'member', memberof: doc.longname});
- if (title === 'Globals') {
- members = self.find({kind: 'member', memberof: {isUndefined: true}});
- }
+ var members = self.find({kind: 'member', memberof: title === 'Globals'? {isUndefined: true} : doc.longname});
if (members && members.length && members.forEach) {
?>
-
<h3 class="subsection-title">Members</h3>
- <dl><?js
- members.forEach(function(p) {
- print(self.partial('members.tmpl', p));
- });
- ?></dl>
-
+ <dl><?js members.forEach(function(p) { ?>
+ <?js= self.partial('members.tmpl', p) ?>
+ <?js }); ?></dl>
<?js } ?>
<?js
- var methods = self.find({kind: 'function', memberof: doc.longname});
- if (title === 'Globals') {
- methods = self.find({kind: 'function', memberof: {isUndefined: true}});
- }
+ var methods = self.find({kind: 'function', memberof: title === 'Globals'? {isUndefined: true} : doc.longname});
if (methods && methods.length && methods.forEach) {
?>
-
<h3 class="subsection-title">Methods</h3>
- <dl><?js
- methods.forEach(function(m) {
- print(self.partial('method.tmpl', m));
- });
- ?></dl>
-
+ <dl><?js methods.forEach(function(m) { ?>
+ <?js= self.partial('method.tmpl', m) ?>
+ <?js }); ?></dl>
<?js } ?>
<?js
var typedefs = self.find({kind: 'typedef', memberof: doc.longname});
if (typedefs && typedefs.length && typedefs.forEach) {
?>
-
<h3 class="subsection-title">TypeDefs</h3>
- <dl><?js
- typedefs.forEach(function(e) {
- print(self.partial('members.tmpl', e));
- });
- ?></dl>
+ <dl><?js typedefs.forEach(function(e) { ?>
+ <?js= self.partial('members.tmpl', e) ?>
+ <?js }); ?></dl>
<?js } ?>
<?js
var events = self.find({kind: 'event', memberof: doc.longname});
if (events && events.length && events.forEach) {
?>
-
<h3 class="subsection-title">Events</h3>
- <dl><?js
- events.forEach(function(e) {
- print(self.partial('method.tmpl', e));
- });
- ?></dl>
+ <dl><?js events.forEach(function(e) { ?>
+ <?js= self.partial('method.tmpl', e) ?>
+ <?js }); ?></dl>
<?js } ?>
</article>
View
45 templates/default/tmpl/details.tmpl
@@ -7,9 +7,7 @@
<h5 class="subsection-title">Properties:</h5>
- <dl><?js
- print( this.partial('properties.tmpl', properties) );
- ?></dl>
+ <dl><?js= this.partial('properties.tmpl', properties) ?></dl>
<?js } ?>
@@ -24,21 +22,18 @@
<?js } ?>
<?js if (data.deprecated) { ?>
- <dt class="important tag-deprecated">Deprecated<?js
- if (data.deprecated === true) print('</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>');
- else print(':</dt><dd><ul class="dummy"><li>'+data.deprecated+'</li><ul></dd>');
+ <dt class="important tag-deprecated">Deprecated:</dt><?js
+ if (data.deprecated === true) { ?><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd><?js }
+ else { ?><dd><ul class="dummy"><li><?js= data.deprecated ?></li><ul></dd><?js }
?>
-
- <?js } ?>
+ <?js } ?>
<?js if (data.author && author.length) {?>
<dt class="tag-author">Author:</dt>
<dd class="tag-author">
- <ul><?js
- author.forEach(function(a) {
- print('<li>'+a+'</li>');
- });
- ?></ul>
+ <ul><?js author.forEach(function(a) { ?>
+ <li><?js= a ?></li>
+ <?js }); ?></ul>
</dd>
<?js } ?>
@@ -65,33 +60,27 @@
<?js if (data.tutorials && tutorials.length) {?>
<dt class="tag-tutorial">Tutorials:</dt>
<dd class="tag-tutorial">
- <ul><?js
- tutorials.forEach(function(t) {
- print('<li>'+self.tutoriallink(t)+'</li>');
- });
- ?></ul>
+ <ul><?js tutorials.forEach(function(t) { ?>
+ <li><?js= tutoriallink(t) ?></li>
+ <?js }); ?></ul>
</dd>
<?js } ?>
<?js if (data.see && see.length) {?>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
- <ul><?js
- see.forEach(function(s) {
- print('<li>'+self.linkto(s)+'</li>');
- });
- ?></ul>
+ <ul><?js see.forEach(function(s) { ?>
+ <li><?js= self.linkto(s) ?></li>
+ <?js }); ?></ul>
</dd>
<?js } ?>
<?js if (data.todo && todo.length) {?>
<dt class="tag-todo">To Do:</dt>
<dd class="tag-todo">
- <ul><?js
- todo.forEach(function(t) {
- print('<li>'+t+'</li>');
- });
- ?></ul>
+ <ul><?js todo.forEach(function(t) { ?>
+ <li><?js= t ?></li>
+ <?js }); ?></ul>
</dd>
<?js } ?>
</dl>
View
17 templates/default/tmpl/exceptions.tmpl
@@ -4,9 +4,7 @@
</div>
<?js } ?>
-<?js
- if (data.type && data.type.names) {
-?>
+<?js if (data.type && data.type.names) { ?>
<dl>
<dt>
Type
@@ -15,14 +13,9 @@
<?js
var typeNames = data.type.names,
self = this;
- typeNames.forEach(function(name, i) {
- ?>
- <span class="param-type"><?js= self.linkto(name, self.htmlsafe(name)) ?></span> <?js if (i < typeNames.length-1) print('|'); ?>
- <?js
- });
- ?>
+ typeNames.forEach(function(name, i) { ?>
+ <span class="param-type"><?js= self.linkto(name, self.htmlsafe(name)) ?></span> <?js if (i < typeNames.length-1) { ?>|<?js } ?>
+ <?js }); ?>
</dd>
</dl>
-<?js
- }
-?>
+<?js } ?>
View
10 templates/default/tmpl/members.tmpl
@@ -15,10 +15,8 @@
<?js= this.partial('details.tmpl', data) ?>
- <?js
- if (data.examples && examples.length) {
- print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
- print( this.partial('examples.tmpl', examples) );
- }
- ?>
+ <?js if (data.examples && examples.length) { ?>
+ <h5>Example<?js= examples.length > 1? 's':'' ?></h5>
+ <?js= this.partial('examples.tmpl', examples) ?>
+ <?js } ?>
</dd>
View
63 templates/default/tmpl/method.tmpl
@@ -14,60 +14,51 @@
</p>
<?js } ?>
- <?js
- if (data['this']) {
- print('<h5>This:</h5>');
- print( '<ul><li>'+this.linkto(data['this'], data['this'])+'</li></ul>' );
- }
- ?>
+ <?js if (data['this']) { ?>
+ <h5>This:</h5>
+ <ul><li><?js= this.linkto(data['this'], data['this']) ?></li></ul>
+ <?js } ?>
- <?js
- if (data.params && params.length) {
- print('<h5>Parameters:</h5>');
- print( this.partial('params.tmpl', params) );
- }
- ?>
+ <?js if (data.params && params.length) { ?>
+ <h5>Parameters:</h5>
+ <?js= this.partial('params.tmpl', params) ?>
+ <?js } ?>
<?js= this.partial('details.tmpl', data) ?>
<?js if (data.fires && fires.length) { ?>
<h5>Fires:</h5>
- <ul><?js
- fires.forEach(function(f) {
- print( self.partial('fires.tmpl', self.linkto(f) ) );
- });
- ?></ul>
+ <ul><?js fires.forEach(function(f) { ?>
+ <?js= self.partial('fires.tmpl', self.linkto(f) ) ?>
+ <?js }); ?></ul>
<?js } ?>
<?js if (data.exceptions && exceptions.length) { ?>
<h5>Throws:</h5>
<?js if (exceptions.length > 1) { ?><ul><?js
- exceptions.forEach(function(r) {
- print( '<li>' + self.partial('exceptions.tmpl', r) + '</li>' );
- });
+ exceptions.forEach(function(r) { ?>
+ <li><?js= self.partial('exceptions.tmpl', r) ?></li>
+ <?js });
?></ul><?js } else {
- exceptions.forEach(function(r) {
- print( self.partial('exceptions.tmpl', r) );
- });
+ exceptions.forEach(function(r) { ?>
+ <?js= self.partial('exceptions.tmpl', r) ?>
+ <?js });
} } ?>
<?js if (data.returns && returns.length) { ?>
<h5>Returns:</h5>
<?js if (returns.length > 1) { ?><ul><?js
- returns.forEach(function(r) {
- print( '<li>' + self.partial('returns.tmpl', r) + '</li>' );
- });
+ returns.forEach(function(r) { ?>
+ <li><?js= self.partial('returns.tmpl', r) ?></li>
+ <?js });
?></ul><?js } else {
- returns.forEach(function(r) {
- print( self.partial('returns.tmpl', r) );
- });
+ returns.forEach(function(r) { ?>
+ <?js= self.partial('returns.tmpl', r) ?>
+ <?js });
} } ?>
- <?js
- if (data.examples && examples.length) {
- print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
- print( this.partial('examples.tmpl', examples) );
- }
- ?>
-
+ <?js if (data.examples && examples.length) { ?>
+ <h5>Example<?js= examples.length > 1? 's':'' ?></h5>
+ <?js= this.partial('examples.tmpl', examples) ?>
+ <?js } ?>
</dd>
View
37 templates/default/tmpl/params.tmpl
@@ -74,41 +74,38 @@
<td class="type">
<?js
if (param.type && param.type.names) {
- param.type.names.forEach(function(name, i) {
- print( self.linkto(name, self.htmlsafe(name)) );
- if (i < param.type.names.length-1) { print(' | '); }
- });
+ param.type.names.forEach(function(name, i) { ?>
+ <?js= self.linkto(name, self.htmlsafe(name)) ?>
+ <?js if (i < param.type.names.length-1) { ?> | <?js } ?>
+ <?js });
}
?>
</td>
<?js if (params.hasAttributes) {?>
<td class="attributes">
- <?js
- if (param.optional) {
- print( '&lt;optional><br>' );
- }
+ <?js if (param.optional) { ?>
+ &lt;optional><br>
+ <?js } ?>
- if (param.nullable) {
- print( '&lt;nullable><br>' );
- }
- ?>
+ <?js if (param.nullable) { ?>
+ &lt;nullable><br>
+ <?js } ?>
</td>
<?js } ?>
<?js if (params.hasDefault) {?>
<td class="default">
- <?js
- if (typeof param.defaultvalue !== 'undefined') {
- print( self.htmlsafe(param.defaultvalue) );
- }
- ?>
+ <?js if (typeof param.defaultvalue !== 'undefined') { ?>
+ <?js= self.htmlsafe(param.defaultvalue) ?>
+ <?js } ?>
</td>
<?js } ?>
- <td class="description last"><?js= param.description ?><?js if (param.subparams) {
- print( '<h6>Properties</h6>' + selfpartial('params.tmpl', param.subparams) );
- }?></td>
+ <td class="description last"><?js= param.description ?><?js if (param.subparams) { ?>
+ <h6>Properties</h6>
+ <?js= self.partial('params.tmpl', param.subparams) ?>
+ <?js } ?></td>
</tr>
<?js }); ?>
View
36 templates/default/tmpl/properties.tmpl
@@ -74,41 +74,37 @@
<td class="type">
<?js
if (prop.type && prop.type.names) {
- prop.type.names.forEach(function(name, i) {
- print( self.linkto(name, self.htmlsafe(name)) );
- if (i < prop.type.names.length-1) { print(' | '); }
- });
+ prop.type.names.forEach(function(name, i) { ?>
+ <?js= self.linkto(name, self.htmlsafe(name)) ?>
+ <?js if (i < prop.type.names.length-1) { ?> | <?js } ?>
+ <?js });
}
?>
</td>
<?js if (props.hasAttributes) {?>
<td class="attributes">
- <?js
- if (prop.optional) {
- print( '&lt;optional><br>' );
- }
+ <?js if (prop.optional) { ?>
+ &lt;optional><br>
+ <?js } ?>
- if (prop.nullable) {
- print( '&lt;nullable><br>' );
- }
- ?>
+ <?js if (prop.nullable) { ?>
+ &lt;nullable><br>
+ <?js } ?>
</td>
<?js } ?>
<?js if (props.hasDefault) {?>
<td class="default">
- <?js
- if (typeof prop.defaultvalue !== 'undefined') {
- print( self.htmlsafe(prop.defaultvalue) );
- }
- ?>
+ <?js if (typeof prop.defaultvalue !== 'undefined') { ?>
+ <?js= self.htmlsafe(prop.defaultvalue) ?>
+ <?js } ?>
</td>
<?js } ?>
- <td class="description last"><?js= prop.description ?><?js if (prop.subprops) {
- print( '<h6>Properties</h6>' + self.partial('properties.tmpl', prop.subprops) );
- }?></td>
+ <td class="description last"><?js= prop.description ?><?js if (prop.subprops) { ?>
+ <h6>Properties</h6><?js= self.partial('properties.tmpl', prop.subprops) ?>
+ <?js } ?></td>
</tr>
<?js }); ?>
View
9 templates/default/tmpl/returns.tmpl
@@ -16,12 +16,9 @@
<dd>
<?js
var self = this;
- names.forEach(function(name, i) {
- ?>
- <span class="param-type"><?js= self.htmlsafe(name) ?></span> <?js if (i < names.length-1) print('|'); ?>
- <?js
- });
- ?>
+ names.forEach(function(name, i) { ?>
+ <span class="param-type"><?js= self.htmlsafe(name) ?></span> <?js if (i < names.length-1) { ?>|<?js } ?>
+ <?js }); ?>
</dd>
</dl>
<?js
View
7 templates/default/tmpl/tutorial.tmpl
@@ -4,10 +4,9 @@
<?js if (children.length > 0) { ?>
<ul><?js
var self = this;
- children.forEach(function(t) {
- print('<li>'+self.tutoriallink(t.name)+'</li>');
- });
- ?></ul>
+ children.forEach(function(t) { ?>
+ <li><?js= self.tutoriallink(t.name) ?></li>
+ <? }); ?></ul>
<?js } ?>
<h2><?js= header ?></h2>

0 comments on commit cd3abea

Please sign in to comment.
Something went wrong with that request. Please try again.