module Roda::RodaPlugins::ErbH

  1. lib/roda/plugins/erb_h.rb

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).


Public Class

  1. load_dependencies

Public Class methods

[show source]
   # File lib/roda/plugins/erb_h.rb
32 def self.load_dependencies(app)
33   app.plugin :h
34 end