Module: Alchemy::BaseHelper

Included in:
Admin::BaseHelper, PagesHelper
Defined in:
app/helpers/alchemy/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_icon(icon_name, options = {}) ⇒ String

Render a Remix icon

Parameters:

  • icon_name (String)

    icon name

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

    a customizable set of options

Options Hash (options):

  • - (Object)

    style: fill [String] icon style. line or fill. Pass false for no style.

  • - (Object)

    size: nil [String] icon size

Returns:

  • (String)


23
24
25
# File 'app/helpers/alchemy/base_helper.rb', line 23

def render_icon(icon_name, options = {})
  render Alchemy::Admin::Icon.new(icon_name, options)
end

#render_message(type = :info, msg = nil) ⇒ Object

Returns a div with an icon and the passed content The default message type is info, but you can also pass other types like :warning or :error

Usage:

<%= render_message :warning do
  <p>Caution! This is a warning!</p>
<% end %>


37
38
39
# File 'app/helpers/alchemy/base_helper.rb', line 37

def render_message(type = :info, msg = nil, &)
  render Alchemy::Admin::Message.new(msg || capture(&), type: type)
end

#warning(message, text = nil) ⇒ Object

Logs a message in the Rails logger (warn level) and optionally displays an error message to the user.



7
8
9
10
11
12
13
14
# File 'app/helpers/alchemy/base_helper.rb', line 7

def warning(message, text = nil)
  Logger.warn(message, caller(1..1))
  unless text.nil?
    render_message(:warning) do
      text.html_safe
    end
  end
end