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