Module: Ronin::App::Helpers::HTML

Defined in:
lib/ronin/app/helpers/html.rb

Overview

HTML helper methods.

Instance Method Summary collapse

Instance Method Details

#h(text) ⇒ String

Escapes the text as HTML text.

Parameters:

  • text (String)

    The string to escape.

Returns:

  • (String)

    The HTML escaped string.



52
53
54
# File 'lib/ronin/app/helpers/html.rb', line 52

def h(text)
  Rack::Utils.escape_html(text.to_s) if text
end

#hattr(text) ⇒ String

Escapes the text as an HTML attribute value.

Parameters:

  • text (String)

    The string to escape.

Returns:

  • (String)

    The escaped HTML attribute.



65
66
67
# File 'lib/ronin/app/helpers/html.rb', line 65

def hattr(text)
  Rack::Utils.escape_path(text.to_s) if text
end

#partial(name, **locals) ⇒ Object

Renders a partial template.

Parameters:

  • name (Symbol)

    The partial template name without the _.

  • locals (Hash{Symbol => Object})

    Additional local variables to pass to the partial.



39
40
41
# File 'lib/ronin/app/helpers/html.rb', line 39

def partial(name,**locals)
  erb(:"_#{name}", layout: nil, locals: locals)
end