Module: Integrity::Helpers::Rendering

Included in:
Integrity::Helpers
Defined in:
lib/integrity/helpers/rendering.rb

Instance Method Summary collapse

Instance Method Details

#checkbox(name, condition, extras = {}) ⇒ Object



33
34
35
36
37
# File 'lib/integrity/helpers/rendering.rb', line 33

def checkbox(name, condition, extras={})
  attrs = { :name => name, :type => "checkbox", :value => "1" }
  attrs[:checked] = !!condition
  attrs.update(extras)
end

#error_class(object, field) ⇒ Object



29
30
31
# File 'lib/integrity/helpers/rendering.rb', line 29

def error_class(object, field)
  object.errors.on(field).nil? ? "" : "with_errors"
end

#errors_on(object, field) ⇒ Object



24
25
26
27
# File 'lib/integrity/helpers/rendering.rb', line 24

def errors_on(object, field)
  return "" unless errors = object.errors.on(field)
  errors.map {|e| e.gsub(/#{field} /i, "") }.join(", ")
end

#notifier_formObject



39
40
41
42
43
44
45
46
# File 'lib/integrity/helpers/rendering.rb', line 39

def notifier_form
  Notifier.available.each_pair { |name, klass|
    haml_concat haml(klass.to_haml, :layout => :notifier, :locals => {
      :notifier => name,
      :enabled  => current_project.notifies?(name),
      :config   => current_project.config_for(name) })
  }
end

#partial(template, locals = {}) ⇒ Object



20
21
22
# File 'lib/integrity/helpers/rendering.rb', line 20

def partial(template, locals={})
  haml("_#{template}".to_sym, :locals => locals, :layout => false)
end

#show(view, options = {}) ⇒ Object



15
16
17
18
# File 'lib/integrity/helpers/rendering.rb', line 15

def show(view, options={})
  @title = breadcrumbs(*options[:title])
  haml view
end

#stylesheet_hashObject



11
12
13
# File 'lib/integrity/helpers/rendering.rb', line 11

def stylesheet_hash
  @_hash ||= Digest::MD5.file(options.views + "/integrity.sass").hexdigest
end

#stylesheets(*sheets) ⇒ Object



4
5
6
7
8
9
# File 'lib/integrity/helpers/rendering.rb', line 4

def stylesheets(*sheets)
  sheets.each { |sheet|
    haml_tag(:link, :href => root_path("/#{sheet}.css"),
      :type => "text/css", :rel => "stylesheet")
  }
end