lib/hanami/view/rendering/templates_finder.rb in hanami-view-0.6.1 vs lib/hanami/view/rendering/templates_finder.rb in hanami-view-0.7.0
- old
+ new
@@ -76,11 +76,26 @@
protected
# @api private
# @since 0.4.3
+ #
+ # Searches first for files at `../templates/articles/index.*.*`
+ # If none are found, falls back to recursive search in `../templates/**/articles/index.*.*`
+ #
def _find(lookup = search_path)
- Dir.glob( "#{ [root, lookup, template_name].join(separator) }.#{ format }.#{ engines }" )
+ base_path = templates_path(root, template_name)
+ if base_path.none?
+ templates_path(root, lookup, template_name)
+ else
+ base_path
+ end
+ end
+
+ # @api private
+ # @since 0.7.0
+ def templates_path(*parts)
+ Dir.glob("#{ parts.join(separator) }.#{ format }.#{ engines }")
end
# @api private
# @since 0.1.0
def template_name