News Update: New Slide Show (S9) Online Service Now Live - Try Slide Show (S9) In Your Browser

Plugins, Helpers and Extensions

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:

## 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:


## Today's Date

{{ Date.today }}

Built-In Helpers

Django-style helper syntax:


{{ include help.txt }}

Classic helper syntax:

<%= include 'help.txt' %>

Django-style:


{{ google_analytics code=UA-YOUR-CODE-HERE }}

Classic:

<%= google_analytics :code => 'UA-YOUR-CODE-HERE' %>

Django-style:


{{ help }}

Classic:

<%= help %>

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 %>

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 %>

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:
  #  ![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:


{{ image friendsbadge.png }}

That’s it. For more samples, check the source of the plugin helpers.

Questions? Comments?

Questions? Comments? Send them along to the wwwmake mailing list/forum. Thanks!

Edit Me! This website is a public GitHub repo. Please help by forking the project and adding to it.