Module: Mantra::Helpers::TemplateHelper
- Defined in:
- lib/mantra/helpers/template_helper.rb
Instance Method Summary collapse
Instance Method Details
#is_scope?(v) ⇒ Boolean
50 51 52 |
# File 'lib/mantra/helpers/template_helper.rb', line 50 def is_scope?(v) v.respond_to?(:is_scope?) && v.is_scope? end |
#templatize(parts) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mantra/helpers/template_helper.rb', line 54 def templatize(parts) merged_parts = [parts.shift] parts.each do |p| if !is_scope?(p) && !is_scope?(merged_parts.last) merged_parts.last.concat(p) else merged_parts << p end end merged_parts.select { |p| !p.empty? }.map do |p| is_scope?(p) ? p : "\"#{p}\"" end end |