Sha256: 6cca34f429a12f20b5ca4812f498adb2f9c6606c76e12fbd35b53fd86bfd3957
Contents?: true
Size: 1.04 KB
Versions: 17
Compression:
Stored size: 1.04 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.underscore(@name) 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
17 entries across 17 versions & 1 rubygems