Module: PinkmanHelper

Defined in:
app/helpers/pinkman_helper.rb

Instance Method Summary collapse

Instance Method Details

#_if(condition, &block) ⇒ Object



44
45
46
# File 'app/helpers/pinkman_helper.rb', line 44

def _if condition, &block
  wrap_in(condition,&block)
end

#_unless(condition, &block) ⇒ Object



48
49
50
# File 'app/helpers/pinkman_helper.rb', line 48

def _unless condition, &block
  raw "\n{{^ #{condition} }}\n \t #{capture(&block)} \n{{/ #{condition} }}\n" if block_given?    
end

#collection(&block) ⇒ Object



24
25
26
# File 'app/helpers/pinkman_helper.rb', line 24

def collection &block
  wrap_in('collection',&block)
end

#each(&block) ⇒ Object



28
29
30
# File 'app/helpers/pinkman_helper.rb', line 28

def each &block
  collection(&block)
end

#input(hash, *args, &block) ⇒ Object



3
4
5
6
7
# File 'app/helpers/pinkman_helper.rb', line 3

def input hash, *args, &block
  name = hash[:name]
  hash[:type] ||= 'text'
  tag('input',hash.merge(data: {pinkey: pinkey, action: name}, value: write(name)), *args, &block)
end

#pinkeyObject



40
41
42
# File 'app/helpers/pinkman_helper.rb', line 40

def pinkey 
  w('pinkey')
end

#template(path) ⇒ Object



16
17
18
# File 'app/helpers/pinkman_helper.rb', line 16

def template path
  render partial: "pinkman/#{path}"
end

#textarea(hash, *args) ⇒ Object



9
10
11
12
13
14
# File 'app/helpers/pinkman_helper.rb', line 9

def textarea hash, *args
  name = hash[:name]
  ('textarea',hash.merge(data: {pinkey: pinkey, action: name}, value: write(name)), *args) do 
    raw(write(name))
  end
end

#w(*args) ⇒ Object



36
37
38
# File 'app/helpers/pinkman_helper.rb', line 36

def w *args
  write(*args)
end

#wrap_in(tag, &block) ⇒ Object



20
21
22
# File 'app/helpers/pinkman_helper.rb', line 20

def wrap_in tag, &block
  raw "\n{{# #{tag} }}\n \t #{capture(&block)} \n{{/ #{tag} }}\n" if block_given?    
end

#write(string) ⇒ Object



32
33
34
# File 'app/helpers/pinkman_helper.rb', line 32

def write string
  raw("{{#{string}}}")
end