module BrainDamage::BrainDamageHelper

Public Instance Methods

T(string) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 70
def T(string)
  t_or_c(string).upcase
end
ajax_sensible_field_wrapper(object, method, show = true, html = {}) { || ... } click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 21
def ajax_sensible_field_wrapper(object, method, show = true, html = {})
  html[:tag] ||= 'tr'
  html[:class] ||= ''
  html[:class] += ' sensible-to-ajax'

  content_tag(html[:tag], { :class => html[:class], :data => { :ajax_sensibility_field => method }}) do
    yield if block_given? and show
  end
end
bd(partial, locals = {}) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 7
def bd(partial, locals = {})
  r "brain_damage/#{partial}", :locals => locals
end
bd_actions(locals = {}, &block) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 16
def bd_actions(locals = {}, &block)
  locals = {:show => false, :delete => true, :edit => true, :block => block}.merge(locals)
  render :partial => 'brain_damage/shared/actions', :locals => locals
end
bd_id(prefix = nil) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 11
def bd_id(prefix = nil)
  prefix = "#{prefix}-" if prefix
  "#{prefix}brain-damage-#{(0...16).map { (65 + rand(26)).chr }.join.downcase}"
end
cet(string) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 61
def cet(string)
  string = t_or_c(string)
  if string == string.upcase
    string
  else
    string.capitalize
  end
end
ct(string) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 51
def ct(string)
  string = t_or_c(string)

  if string == string.upcase
    string
  else
    string.capitalize
  end
end
name_for_input_tag(attribute_name, prefix = nil) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 31
def name_for_input_tag(attribute_name, prefix = nil)
  if prefix
    return "#{prefix}[#{attribute_name}]"
  end

  attribute_name
end
r(partial, locals = {}) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 3
def r(partial, locals = {})
  render :partial => partial, :locals => locals
end
t_or_c(string) click to toggle source
# File lib/brain_damage/brain_damage_helper.rb, line 39
def t_or_c(string)
  return t string if I18n.exists? string

  common = "common.#{string.split('.').last}"
  return t common if I18n.exists? common

  entities = "entities.#{string.split('.').last}"
  return t entities if I18n.exists? entities

  t string
end