Conditions | 3 |
Total Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | # This inserts a partial into a HAML document. |
||
11 | def partial(template, *args) |
||
12 | template_array = template.to_s.split('/') |
||
13 | template = "#{template_array[0..-2].join('/')}/_#{template_array[-1]}" |
||
14 | options = args.last.is_a?(Hash) ? args.pop : {} |
||
15 | options.merge!(:layout => false) |
||
16 | locals = options[:locals] || {} |
||
17 | collection == options.delete(:collection) ? |
||
18 | collection.inject([]) { |buffer, member| buffer << haml(:"#{template}", options.merge(:layout => false, |
||
19 | :locals => {template_array[-1].to_sym => member}.merge(locals))) }.join("\n") : |
||
20 | haml(:"#{template}", options) |
||
21 | end |
||
22 | end |
||
23 |