Module: Papercraft::Compiler::AuxMethods

Included in:
Papercraft
Defined in:
lib/papercraft/compiler.rb

Instance Method Summary collapse

Instance Method Details

#format_html_attr(tag) ⇒ Object



9
10
11
# File 'lib/papercraft/compiler.rb', line 9

def format_html_attr(tag)
  tag.to_s.tr('_', '-')
end

#format_html_attrs(attrs) ⇒ Object



13
14
15
16
17
18
# File 'lib/papercraft/compiler.rb', line 13

def format_html_attrs(attrs)
  attrs.reduce(+'') do |html, (k, v)|
    html << ' ' if !html.empty?
    html << "#{format_html_attr(k)}=\"#{v}\""
  end
end

#render_emit_call(o, *a, **b, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/papercraft/compiler.rb', line 20

def render_emit_call(o, *a, **b, &block)
  case o
  when nil
    # do nothing
  when Papercraft::Template
    o.render(*a, **b, &block)
  when ::Proc
    Papercraft.html(&o).render(*a, **b, &block)
  else
    o.to_s
  end
end