SummaryGenerate arbitrary output using plain Ruby
Short nameruby
Content typetext
Provided by bundlebuilt-in
API docWebgen::ContentProcessor::Ruby


This processor assumes that the content is valid Ruby code which means that you have the full power of Ruby available for generating content.


You can use the special context object in the Ruby code which is an instance of Webgen::Context and provides the rendering context and many useful methods. The methods from the ERB::Utils module are also available.

When using this processor you should set the context.content to the content that you want to generate.


Here is a small example. If this text is put in a page file

data = do |k,v|
 "<li><b>#{h(k)}</b>: #{h(v)}</li>\n"

context.content = "<ul>\n#{data.join("")}</ul>"

… it will give this result:

<li><b>handler</b>: page</li>
<li><b>blocks</b>: {&quot;defaults&quot;=&gt;{&quot;pipeline&quot;=&gt;[&quot;erb&quot;, &quot;tags&quot;, &quot;kramdown&quot;, &quot;blocks&quot;, &quot;fragments&quot;]}, &quot;example&quot;=&gt;{&quot;pipeline&quot;=&gt;&quot;ruby&quot;}}</li>
<li><b>modified_at</b>: 2013-03-03 20:53:24 +0100</li>
<li><b>title</b>: content_processor.ruby</li>
<li><b>version</b>: default</li>
<li><b>node_class</b>: Webgen::PathHandler::PageUtils::Node</li>
<li><b>dest_path</b>: &lt;parent&gt;&lt;basename&gt;(-&lt;version&gt;)(-&lt;modified_at&gt;)(.&lt;lang&gt;)&lt;ext&gt;</li>
<li><b>template</b>: /templates/documentation/content_processor.template</li>
<li><b>link</b>: {&quot;prev&quot;=&gt;&quot;/documentation/reference/extensions/content_processor/redcloth.en.html&quot;, &quot;next&quot;=&gt;&quot;/documentation/reference/extensions/content_processor/sass.en.html&quot;}</li>

See how the context.content is assigned the generated content. And how the ERB::Utils#h method is used for escaping special HTML characters!