Sha256: bef3265d07c19e7eebbab202f90a102e43cbd62c13327651ae1657cabdee01ef
Contents?: true
Size: 776 Bytes
Versions: 5
Compression:
Stored size: 776 Bytes
Contents
require 'hanami/utils/string' module Hanami module View module Rendering # @since 0.2.0 class TemplateName NAMESPACE_SEPARATOR = '::'.freeze def initialize(name, namespace) @name = name compile!(namespace) end def to_s @name end private def compile!(namespace) tokens(namespace) {|token| replace!(token) } @name = Utils::String.new(@name).underscore end def tokens(namespace) namespace.to_s.split(NAMESPACE_SEPARATOR).each do |token| yield token end end def replace!(token) @name.gsub!(%r{\A#{ token }#{ NAMESPACE_SEPARATOR }}, '') end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems