Sha256: f8103518f00fa03ee06e0c10ddbe27af79badb95225b537747dc0496cacb5f59
Contents?: true
Size: 1.05 KB
Versions: 1
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.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 = @name.gsub(%r{\A#{ token }#{ NAMESPACE_SEPARATOR }}, '') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanami-view-1.3.3 | lib/hanami/view/rendering/template_name.rb |