title |
---|
Plugins, Helpers and Extensions |
Slide Show (S9) includes support for plugins and helpers and lets you use Embedded Ruby (ERB) in your slide source. Example:
## Today's Date
<%= Date.today %>
If you want to use your own helpers put your code in the ./lib
folder (or any subfolders) and your code gets loaded on startup.
Note, as an alternative syntax for Embedded Ruby (ERB) helpers you can also
use a Django-style syntax using {% raw %}{{ }}{% endraw %}
. Example:
{% raw %}
## Today's Date
{{ Date.today }}
{% endraw %}
include
- Lets you include text. Example:
Django-style helper syntax:
|
Classic helper syntax:
|
google_analytics
- Lets you add tracker code for Google Analytics. Example:
Django-style:
|
Classic:
|
help
- Lets you add key control help information for the S6 slide show machinery. Example:
Django-style:
|
Classic:
|
left
/right
- Lets you use two-column layouts in your slides. Example:
Django-style:
|
Classic:
|
step
- Lets you wrap a block into a div for incremental display using steps. Example:
Django-style:
|
Classic:
|
content_for
- Lets you add content to your templates from your source a la Rails.
In your slide source use:
<% content_for :head do %>
your content here e.g. more meta tags; javascript includes etc.
<% end %>
In your template use:
<%= content_for :head %>
and it will include the marked content from your source.
Note, you can use :foo
, :bar
or whatever key you
want instead of :head
and also note a la Rails you can use the same
key as many times as you want. The new content just gets added.
Use the code
helper to include and syntax highlight code. More »
Let's create a helper called image
as a shortcut for
adding embedded images to your slides in Markdown syntax.
Let's create a new Ruby script (file) e.g. markdown_helper.rb
and let's pack our new helper into a module named MarkdownHelper
Example:
module MarkdownHelper
# helper/shortcut for adding embedded image to slide in markdown syntax:
# ![alt text](/path/to/img.jpg "Title")
#
# use it like:
# <%= image 'friendsbadge.png' %>
#
# note: alternate text (alt) and title are optional
def image( path, alt="", title="" )
%Q{![#{alt}](#{path} "#{title}")}
end
end
Almost done. Two more steps. Include your code into
the class Slideshow::Gen
. Add this snippet to the end of your
Ruby script:
class Slideshow::Gen
include MarkdownHelper
end
Lastly, make sure your Ruby script (that is, markdown_helper.rb
)
resides in the ./lib
folder (or any subfolders) of your working folder
and your code will get loaded on startup and is ready for use in your
slides. Example:
<%= image 'friendsbadge.png' %>
Or Django-style:
{% raw %}
{{ image friendsbadge.png }}
{% endraw %}
That's it. For more samples, check the source of the plugin helpers.