Module: Roda::RodaPlugins::ErbH

Defined in:


The erb_h plugin adds an h instance method that will HTML escape the input and return it. This is similar to the h plugin, but it uses erb/escape to implement the HTML escaping, which offers faster performance.

To make sure that this speeds up applications using the h plugin, this depends on the h plugin, and overrides the h method.

The following example will return “<foo>” as the body.

plugin :erb_h

route do |r|

The faster performance offered by the erb_h plugin is due to erb/escape avoiding allocations if not needed (returning the input object if no escaping is needed). That behavior change can cause problems if you mutate the result of the h method (which can mutate the input), or mutate the input of the h method after calling it (which can mutate the result).

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.load_dependencies(app) ⇒ Object

# File 'lib/roda/plugins/erb_h.rb', line 32

def self.load_dependencies(app)
  app.plugin :h