Module: UltraSettings::RenderHelper

Included in:
ApplicationView, ConfigurationView
Defined in:
lib/ultra_settings/render_helper.rb

Overview

Helper methods for rendering views.

Instance Method Summary collapse

Instance Method Details

#html_escape(value) ⇒ String

HTML escape a value.

Parameters:

  • value (String)

    The value to escape.

Returns:

  • (String)

    The escaped value.



10
11
12
# File 'lib/ultra_settings/render_helper.rb', line 10

def html_escape(value)
  ERB::Util.html_escape(value)
end

#render_partial(partial_name, locals = {}) ⇒ String

Render a partial template with the given locals.

Parameters:

  • partial_name (String)

    The name of the partial template (without the leading underscore and file extension).

  • locals (Hash) (defaults to: {})

    A hash of local variables to pass to the template.

Returns:

  • (String)

    The rendered HTML of the partial.



19
20
21
22
23
24
25
26
# File 'lib/ultra_settings/render_helper.rb', line 19

def render_partial(partial_name, locals = {})
  template = ViewHelper.erb_template("_#{partial_name}.html.erb")
  b = binding
  locals.each do |key, value|
    b.local_variable_set(key, value)
  end
  template.result(b)
end