Method: MustacheRender::Mustache.underscore

Defined in:
lib/mustache_render/mustache.rb

.underscore(classified = name) ⇒ Object

TemplatePartial => template_partial Template::Partial => template/partial Takes a string but defaults to using the current class’ name.



229
230
231
232
233
234
235
236
237
238
239
# File 'lib/mustache_render/mustache.rb', line 229

def self.underscore(classified = name)
  classified = name if classified.to_s.empty?
  classified = superclass.name if classified.to_s.empty?

  string = classified.dup.split("#{view_namespace}::").last

  string.split('::').map do |part|
    part[0] = part[0].chr.downcase
    part.gsub(/[A-Z]/) { |s| "_#{s.downcase}"}
  end.join('/')
end