Class: ActionView::Resolver::PathParser
- Inherits:
-
Object
- Object
- ActionView::Resolver::PathParser
- Defined in:
- lib/action_view/template/resolver.rb
Overview
:nodoc:
Defined Under Namespace
Classes: ParsedPath
Instance Method Summary collapse
Instance Method Details
#build_path_regex ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/action_view/template/resolver.rb', line 19 def build_path_regex handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|") formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|") locales = "[a-z]{2}(?:-[A-Z]{2})?" variants = "[^.]*" %r{ \A (?:(?<prefix>.*)/)? (?<partial>_)? (?<action>.*?) (?:\.(?<locale>#{locales}))?? (?:\.(?<format>#{formats}))?? (?:\+(?<variant>#{variants}))?? (?:\.(?<handler>#{handlers}))? \z }x end |
#parse(path) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/action_view/template/resolver.rb', line 38 def parse(path) @regex ||= build_path_regex match = @regex.match(path) path = TemplatePath.build(match[:action], match[:prefix] || "", !!match[:partial]) details = TemplateDetails.new( match[:locale]&.to_sym, match[:handler]&.to_sym, match[:format]&.to_sym, match[:variant]&.to_sym ) ParsedPath.new(path, details) end |