Skip to content

Commit

Permalink
Merge branch 'master' into 0.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jul 22, 2016
2 parents f81a987 + fd219cf commit bbb667c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,7 +1,7 @@
# Hanami::View
View layer for Hanami

## v0.7.0 - (unreleased)
## v0.7.0 - 2016-07-22
### Added
- [Luca Guidi] Introduced `#local` for views, layouts and templates. It allows to safely access locals without raising errors in case the referenced local is missing.

Expand Down
6 changes: 3 additions & 3 deletions lib/hanami/view/configuration.rb
Expand Up @@ -427,7 +427,7 @@ def load!
# Load partials for each partial template file found under the
# given load paths
#
# @since x.x.x
# @since 0.7.0
# @api private
def load_partials!
Hanami::View::Rendering::PartialTemplatesFinder.new(self).find.each do |partial|
Expand All @@ -438,7 +438,7 @@ def load_partials!
# Load partials for each partial template file found under the
# given load paths
#
# @since x.x.x
# @since 0.7.0
# @api private
def find_partial(relative_partial_path, template_name, format)
partials_for_view = partials.has_key?(relative_partial_path) ? partials[relative_partial_path] : partials[template_name]
Expand All @@ -447,7 +447,7 @@ def find_partial(relative_partial_path, template_name, format)

# Add a partial to the registry
#
# @since x.x.x
# @since 0.7.0
# @api private
def add_partial(partial)
@partials[partial.key][partial.format.to_sym] = partial.template
Expand Down
6 changes: 3 additions & 3 deletions lib/hanami/view/escape.rb
Expand Up @@ -122,7 +122,7 @@ def _escape(object)
module Presentable
# Inject escape logic into the given class.
#
# @since x.x.x
# @since 0.7.0
# @api private
#
# @see Hanami::View::Escape
Expand All @@ -134,7 +134,7 @@ def self.included(base)
#
# @param object [Object] the object to present
#
# @since x.x.x
# @since 0.7.0
def initialize(object)
@object = object
end
Expand All @@ -144,7 +144,7 @@ def initialize(object)
# Override Ruby's method_missing
#
# @api private
# @since x.x.x
# @since 0.7.0
def method_missing(m, *args, &blk)
if @object.respond_to?(m)
::Hanami::View::Escape.html(@object.__send__(m, *args, &blk))
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/view/rendering.rb
Expand Up @@ -110,7 +110,7 @@ def render
#
# @return [Objeect,Hanami::View::Rendering::NullLocal] the returning value
#
# @since x.x.x
# @since 0.7.0
#
# @example
# <% if local(:plan).overdue? %>
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/view/rendering/layout_scope.rb
Expand Up @@ -172,7 +172,7 @@ def content(key)
#
# @return [Objeect,Hanami::View::Rendering::NullLocal] the returning value
#
# @since x.x.x
# @since 0.7.0
#
# @example Safe method navigation
# <% if local(:plan).overdue? %>
Expand Down
22 changes: 11 additions & 11 deletions lib/hanami/view/rendering/null_local.rb
Expand Up @@ -5,47 +5,47 @@ module View
module Rendering
# Null local
#
# @since x.x.x
# @since 0.7.0
#
# @see Hanami::View::Rendering#local
class NullLocal < Utils::BasicObject
# @since x.x.x
# @since 0.7.0
# @api private
TO_STR = "".freeze

# @since x.x.x
# @since 0.7.0
# @api private
def initialize(local)
@local = local
end

# @since x.x.x
# @since 0.7.0
def all?
false
end

# @since x.x.x
# @since 0.7.0
def any?
false
end

# @since x.x.x
# @since 0.7.0
def empty?
true
end

# @since x.x.x
# @since 0.7.0
def nil?
true
end

# @since x.x.x
# @since 0.7.0
# @api private
def to_str
TO_STR
end

# @since x.x.x
# @since 0.7.0
# @api private
def method_missing(m, *)
if m.match(/\?\z/)
Expand All @@ -57,13 +57,13 @@ def method_missing(m, *)

private

# @since x.x.x
# @since 0.7.0
# @api private
def respond_to_missing?(method_name, include_all)
true
end

# @since x.x.x
# @since 0.7.0
# @api private
def __inspect
" :#{ @local }"
Expand Down
4 changes: 2 additions & 2 deletions lib/hanami/view/rendering/partial_file.rb
@@ -1,12 +1,12 @@
module Hanami
module View
module Rendering
# @since x.x.x
# @since 0.7.0
# @api private
class PartialFile
attr_reader :key, :format, :template

# @since x.x.x
# @since 0.7.0
# @api private
def initialize(key, format, template)
@key = key
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/view/rendering/partial_finder.rb
Expand Up @@ -41,7 +41,7 @@ def find

protected

# @since x.x.x
# @since 0.7.0
# @api private
def relative_partial_path
[view_template_dir, template_name].join(separator)
Expand Down
12 changes: 6 additions & 6 deletions lib/hanami/view/rendering/partial_templates_finder.rb
Expand Up @@ -7,18 +7,18 @@ module Rendering
# Find partial templates in the file system
#
# @api private
# @since x.x.x
# @since 0.7.0
#
# @see View::Template
class PartialTemplatesFinder
# Search pattern for partial file names
#
# @api private
# @since x.x.x
# @since 0.7.0
PARTIAL_PATTERN = '_*'.freeze

# @api private
# @since x.x.x
# @since 0.7.0
PARTIAL_PARTS_SEPARATOR = '.'.freeze

attr_reader :configuration
Expand All @@ -27,7 +27,7 @@ class PartialTemplatesFinder
#
# @param configuration [Configuration] the configuration object
#
# @since x.x.x
# @since 0.7.0
def initialize(configuration)
@configuration = configuration
end
Expand All @@ -36,7 +36,7 @@ def initialize(configuration)
#
# @return [Array] array of PartialFinder objects
#
# @since x.x.x
# @since 0.7.0
def find
_find_partials(configuration.root).map do |template|
partial_path, partial_base_name = Pathname(template).relative_path_from(configuration.root).split
Expand All @@ -58,7 +58,7 @@ def find
#
# @return [Array] an array of strings for each matching partial template file found
#
# @since x.x.x
# @since 0.7.0
# @api private
def _find_partials(path)
Dir.glob("#{ [path, TemplatesFinder::RECURSIVE, PARTIAL_PATTERN].join(::File::SEPARATOR) }.#{TemplatesFinder::FORMAT}.#{TemplatesFinder::ENGINES}")
Expand Down

0 comments on commit bbb667c

Please sign in to comment.