Class: Greenmat::Render::Safe

Inherits:
HTML
  • Object
show all
Defined in:
lib/greenmat.rb

Overview

A renderer object you can use to deal with users' input. It enables escape_html and safe_links_only by default.

The block_code callback is also overriden not to include the lang's class as the user can basically specify anything with the vanilla one.

Instance Method Summary collapse

Constructor Details

#initialize(extensions = {}) ⇒ Safe

Returns a new instance of Safe.



31
32
33
34
35
36
# File 'lib/greenmat.rb', line 31

def initialize(extensions = {})
  super({
    escape_html: true,
    safe_links_only: true
  }.merge(extensions))
end

Instance Method Details

#block_code(code, lang) ⇒ Object



38
39
40
41
42
# File 'lib/greenmat.rb', line 38

def block_code(code, lang)
  "<pre>" \
    "<code>#{html_escape(code)}</code>" \
  "</pre>"
end