Webgen::ContentProcessor::Erubis

Summary

As short name for the content processor (used, for example, in the pipeline option of a block in a file in Webgen Page Format) one of the following can be used: erubis.

Description

This processor uses the Erubis library to process embedded Ruby statements. Erubis is quite a bit faster than the standard ERB library that is shipped with Ruby and provides many other useful options.

This extension is only available if you have installed the erubis library. The preferred way to do this is via Rubygems:

gem install erubis

You can use some special objects provided by webgen in your embedded Ruby code. These are the same objects that are available to the erb processor, have a look at its documentation page.

The default mode of Erubis works like ERB. So everyting said on the erb page is also true for Erubis. However, you can customize how this processor works by using the following configuration options:

  • contentprocessor.erubis.use_pi: Use processing instructions instead of ERB like instructions. Normally you use statements like <% result = some_method_call(opts) %> or <%= context.content_node.alcn %> in your content. When setting this option to true, you can use XML processing instructions instead, like this: <?rb result = some_method_call(opts) ?> or @{context.content_node.alcn}@.

  • contentprocessor.erubis.options: This is hash which is passed to the Erubis interpreter and which can be used to set additional options.

For more information on the additional options or on how to use the processing instructions mode of Erubis, have a look at the Erubis User Guide!

You can also use block options to modify the behavior of Erubis. The block option erubis_use_pi is used instead of the configuration option contentprocessor.erubis.use_pi and all other block options starting with erubis_ are added the options hash that is passed to the Erubis interpreter. For example, the following page tells the Erubis interpreter to use the processing instructions mode and to trim spaces:

--- erubis_use_pi:true erubis_trim:true
Here are the numbers from 1 to 5:
<?rb for i in [1,2,3,4,5] ?>@{i}@<?rb end ?>