Wunderbar is extensible in a number of directions. Extensions may be as
simple as adding a few <script>
and/or <link>
statements to the <head>
section of the resulting page using
assets.
Or declaratively using
templates.
Or programmatically by extending
Wunderbar::HtmlMarkup.
While extensions may be defined outside of Wunderbar; Wunderbar includes a
number of extensions. Including an extension is generally as simple as
require 'wunderbar/extension-name'
.
Following is a brief description of each of the extensions included with Wunderbar.
This adds a _coderay
macro that accepts a language (as a symbol), a String,
and an optional hash. The string is passed through
coderay and the result embedded in a pre
element. If attributes are provided, they are added to the pre
element.
This extension adds a _coffeescript
macro that accepts a string. The string
is converted to Javascript and the tag is replace with a script
.
Adds a _.submit
method which daemonizes a command or block. The websocket
extension makes use of this.
This extension adds a link statement to the jquery library. If you require
jquery/stupidtable
instead, you get both libraries.
If Ruby2JS is available, then the jquery script filters are also loaded.
Demos:
This extension introduces a _markdown
macro that takes a string and
interprets it as markdown,
and adds the HTML fragment produced into the current document.
This extension requires kramdown and nokogiri.
Demo:
Converts blocks passed to _script
from Ruby to JavaScript using
Opal. This functionality is not compatible with the
script extension which does something similar using Ruby2JS.
Additional Opal functionality can be obtained if you add
require opal/browser
or require opal/jquery
.
Requires sourcify, opal (and optionally, opal-jquery or opal-browser, once it becomes available.
Demos:
Adds _polymer_element
to the list of data types supported by Wunderbar.
If used with Sinatra, will define the appropriate helpers too.
Demo:
Deploys a wunderbar application as a Rack application, enabling integration with a wide (and growing) list of Rack servers.
Demo:
Converts blocks passed to _script
from Ruby to JavaScript. If Sinatra is in
use, also defines a _js
helper as well as defining a template for files with
an extension of _js
.
Instance variables defined in the calling script are made available to the script. As such values are converted to JavaScript, they are limited to Integers, Floats, Strings, Symbols, and Arrays or Hashes containing only these types.
Requires the ruby2js gem to be installed.
If the binding_of_caller gem is available (i.e., was previously required), then local variables of the caller are also made available.
Adds helpers and templates enabling Wunderbar to be used with Sinatra.
_html
, _json
, _text
, and _template
may be used directly inside Sinatra
scripts using constructs such as _html do...end
, or in views using
_html :viewName
. Extensions for Wunderbar views are _html
, _json
,
etcetera.
Demos:
This extension defines a thin wrapper over Event Machine's web socket interface. Requires the em-websocket gem to be installed.
Demos:
As a bonus for following along this far, there is a demo Calendar application implemented with Wunderbar.