Skip to content

Commit

Permalink
Refactored slides into its own template
Browse files Browse the repository at this point in the history
  • Loading branch information
jdan committed Sep 10, 2013
1 parent 0cd846a commit c70809c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
26 changes: 17 additions & 9 deletions lib/cleaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function Cleaver(file) {
this.templates = {
main: 'layout.mustache',
author: 'author.mustache',
agenda: 'agenda.mustache'
agenda: 'agenda.mustache',
slides: 'default.mustache'
};

this.resources = {
Expand Down Expand Up @@ -88,24 +89,31 @@ Cleaver.prototype._loadAssets = function () {
*/
Cleaver.prototype._renderSlideshow = function () {
var putControls = this.metadata.controls || (this.metadata.controls === undefined);
var outputLocation = this.metadata.output || path.basename(this.file, '.md') + '-cleaver.html';

// Render the slides in a template (maybe as specified by the user)
var slideshow = mustache.render(this.templates.loaded.slides, {
slides: this.slides,
controls: putControls,
// TODO: uglify navigation.js?
navigation: this.resources.loaded.navigation
});

// TODO: handle defaults gracefully
var title = this.metadata.title || 'Untitled';
var encoding = this.metadata.encoding || 'utf-8';

var slideData = {
slides: this.slides,
var layoutData = {
slideshow: slideshow,
title: title,
encoding: encoding,
controls: putControls,
style: this.resources.loaded.style,
externalStyle: this.external.loaded.style,
// TODO: uglify navigation.js?
navigation: this.resources.loaded.navigation
externalStyle: this.external.loaded.style
};

return helper.save(outputLocation, mustache.render(this.templates.loaded.main, slideData));
// Render the main layout
var outputLocation = this.metadata.output || path.basename(this.file, '.md') + '-cleaver.html';

return helper.save(outputLocation, mustache.render(this.templates.loaded.layout, layoutData));
}


Expand Down
15 changes: 15 additions & 0 deletions templates/default.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="wrapper">
{{#slides}}
<section class="slide">{{{.}}}</section>
{{/slides}}
</div>
{{#controls}}
<div id="controls">
<div id="prev">&larr;</div>
<div id="next">&rarr;</div>
</div>
{{/controls}}

<script type="text/javascript">
{{{navigation}}}
</script>
15 changes: 1 addition & 14 deletions templates/layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
</style>
</head>
<body>
<div id="wrapper">
{{#slides}}
<section class="slide">{{{.}}}</section>
{{/slides}}
</div>
{{#controls}}
<div id="controls">
<div id="prev">&larr;</div>
<div id="next">&rarr;</div>
</div>
{{/controls}}
<script type="text/javascript">
{{{navigation}}}
</script>
{{{slideshow}}}
</body>
</html>

0 comments on commit c70809c

Please sign in to comment.