Plugins, Helpers and Extensions
Contents:
Using Embedded Ruby (ERB) Helpers in Your Slides
Slide Show (S9) includes support for plugins and helpers and lets you use Embedded Ruby (ERB) in your slide source. Example:
h1. 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 {{ }}. Example:
h1. Today's Date
{{ Date.today }}
Built-In Helpers
include– Lets you include text. Example:
|
Django-style helper syntax:
{{ include help.txt }}
|
Classic helper syntax: <%= include 'help.txt' %> |
google_analytics– Lets you add tracker code for Google Analytics. Example:
|
Django-style:
{{ google_analytics code=UA-YOUR-CODE-HERE }}
|
Classic: <%= google_analytics :code => 'UA-YOUR-CODE-HERE' %> |
help– Lets you add key control help information for the S6 slide show machinery. Example:
|
Django-style:
{{ help }}
|
Classic: <%= help %> |
left/right– Lets you use two-column layouts in your slides. Example:
|
Django-style:
{% left %}
### Java is
* Strongly,
* Statically,
* Manifestly
typed.
{% end %}
{% right %}
### Ruby is
* Strongly,
* Dynamically,
* Implicitly
typed.
{% end %}
|
Classic: <% left do %> ### Java is * Strongly, * Statically, * Manifestly typed. <% end %> <% right do %> ### Ruby is * Strongly, * Dynamically, * Implicitly typed. <% end %> |
step– Lets you wrap a block into a div for incremental display using steps. Example:
|
Django-style:
{% step %}
* Catching all inappropriate operations on a type, either at
* compile time, or
* run time
{% end %}
|
Classic: <% step do %> * Catching all inappropriate operations on a type, either at * compile time, or * run time <% end %> |
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.
Code/Syntax Highlighting Helpers
Use the code helper to include and syntax highlight code. More »
How to Create Your Own Helpers
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:
# 
#
# use it like:
# <%= image 'friendsbadge.png' %>
#
# note: alternate text (alt) and title are optional
def image( path, alt="", title="" )
%Q{}
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:
{{ image friendsbadge.png }}
That’s it. For more samples, check the source of the built-in helpers.
Questions? Comments?
Questions? Comments? Send them along to the Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List. Thanks!