Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass options to slide template rendering #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ Cleaver.prototype.loadStaticAssets = function () {
Cleaver.prototype.renderSlideshow = function () {
var putControls = this.options.controls || (this.options.controls === undefined);
var putProgress = this.options.progress || (this.options.progress === undefined);
var options = Object.assign({}, this.options, { controls: putControls, progress: putProgress });

var style, script, output;

// Render the slides in a template (maybe as specified by the user)
var slideshow = mustache.render(this.templates.loaded.slides, {
slides: this.slides,
options: options,
controls: putControls,
progress: putProgress
});
Expand Down Expand Up @@ -255,7 +258,7 @@ Cleaver.prototype.renderSlideshow = function () {
style: style,
author: this.options.author,
script: script,
options: this.options
options: options
};

/* Return the rendered slideshow */
Expand Down
8 changes: 4 additions & 4 deletions templates/default.mustache
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{{#progress}}
{{#options.progress}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supposedly, this one would work without options as well, right? Did you update this to show people the possibility of using this or just to make something else work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct. I think it might make sense to try and make the progress and controls a bit less "magical" and a bit more like something you could write yourself (i.e. in a theme) without having to modify any of the cleaver core files.

For that reason I'd also suggest deprecating/removing the progress and options variables here (this change would be required to make that happen) at some point.

<div class="progress">
<div class="progress-bar"></div>
</div>
{{/progress}}
{{/options.progress}}

{{#slides}}
<div class="slide{{#hidden}} hidden{{/hidden}}{{#classList}} {{classList}}{{/classList}}" id="slide-{{id}}">
<section class="slide-content">{{{content}}}</section>
</div>
{{/slides}}

{{#controls}}
{{#options.controls}}
<div class="controls">
<div class="arrow prev"></div>
<div class="arrow next"></div>
</div>
{{/controls}}
{{/options.controls}}