hanami-view 2.1.0.rc1 → 2.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/hanami-view.gemspec +0 -1
- data/lib/hanami/view/cache.rb +8 -1
- data/lib/hanami/view/context.rb +5 -0
- data/lib/hanami/view/decorated_attributes.rb +8 -0
- data/lib/hanami/view/erb/engine.rb +1 -1
- data/lib/hanami/view/erb/filters/block.rb +1 -1
- data/lib/hanami/view/erb/filters/trimming.rb +1 -1
- data/lib/hanami/view/erb/parser.rb +1 -1
- data/lib/hanami/view/erb/template.rb +1 -1
- data/lib/hanami/view/errors.rb +12 -20
- data/lib/hanami/view/exposure.rb +32 -0
- data/lib/hanami/view/exposures.rb +19 -0
- data/lib/hanami/view/helpers/escape_helper.rb +15 -15
- data/lib/hanami/view/helpers/number_formatting_helper.rb +13 -13
- data/lib/hanami/view/helpers/tag_helper/tag_builder.rb +21 -21
- data/lib/hanami/view/helpers/tag_helper.rb +8 -8
- data/lib/hanami/view/html.rb +14 -9
- data/lib/hanami/view/html_safe_string_buffer.rb +1 -1
- data/lib/hanami/view/part.rb +29 -12
- data/lib/hanami/view/part_builder.rb +6 -4
- data/lib/hanami/view/path.rb +14 -0
- data/lib/hanami/view/rendered.rb +13 -7
- data/lib/hanami/view/renderer.rb +17 -0
- data/lib/hanami/view/rendering.rb +17 -0
- data/lib/hanami/view/rendering_missing.rb +15 -0
- data/lib/hanami/view/scope.rb +23 -16
- data/lib/hanami/view/scope_builder.rb +5 -3
- data/lib/hanami/view/tilt/haml_adapter.rb +2 -0
- data/lib/hanami/view/tilt/slim_adapter.rb +2 -0
- data/lib/hanami/view/tilt.rb +5 -0
- data/lib/hanami/view/version.rb +3 -2
- data/lib/hanami/view.rb +69 -30
- metadata +3 -18
- data/lib/hanami/view/application_view.rb +0 -89
@@ -1,89 +0,0 @@
|
|
1
|
-
module Hanami
|
2
|
-
class View
|
3
|
-
class ApplicationView < Module
|
4
|
-
InheritedHook = Class.new(Module)
|
5
|
-
|
6
|
-
attr_reader :provider
|
7
|
-
attr_reader :application
|
8
|
-
attr_reader :inherited_hook
|
9
|
-
|
10
|
-
def initialize(provider)
|
11
|
-
@provider = provider
|
12
|
-
@application = provider.respond_to?(:application) ? provider.application : Hanami.application
|
13
|
-
@inherited_hook = InheritedHook.new
|
14
|
-
|
15
|
-
define_inherited_hook
|
16
|
-
end
|
17
|
-
|
18
|
-
def included(view_class)
|
19
|
-
configure_view view_class
|
20
|
-
view_class.extend inherited_hook
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def configure_view(view_class)
|
26
|
-
view_class.settings.each do |setting|
|
27
|
-
if application.config.views.respond_to?(:"#{setting}")
|
28
|
-
application_value = application.config.views.public_send(:"#{setting}")
|
29
|
-
view_class.config.public_send :"#{setting}=", application_value
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
view_class.config.inflector = provider.inflector
|
34
|
-
view_class.config.paths = prepare_paths(provider, view_class.config.paths)
|
35
|
-
view_class.config.template = template_name(view_class)
|
36
|
-
|
37
|
-
if (part_namespace = namespace_from_path(application.config.views.parts_path))
|
38
|
-
view_class.config.part_namespace = part_namespace
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def define_inherited_hook
|
43
|
-
template_name = method(:template_name)
|
44
|
-
|
45
|
-
inherited_hook.send :define_method, :inherited do |subclass|
|
46
|
-
super(subclass)
|
47
|
-
subclass.config.template = template_name.(subclass)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def prepare_paths(provider, configured_paths)
|
52
|
-
configured_paths.map { |path|
|
53
|
-
if path.dir.relative?
|
54
|
-
provider.root.join(path.dir)
|
55
|
-
else
|
56
|
-
path
|
57
|
-
end
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def template_name(view_class)
|
62
|
-
provider
|
63
|
-
.inflector
|
64
|
-
.underscore(view_class.name)
|
65
|
-
.sub(/^#{provider.namespace_path}\//, "")
|
66
|
-
.sub(/^#{view_class.config.template_inference_base}\//, "")
|
67
|
-
end
|
68
|
-
|
69
|
-
def namespace_from_path(path)
|
70
|
-
path = "#{provider.namespace_path}/#{path}"
|
71
|
-
|
72
|
-
begin
|
73
|
-
require path
|
74
|
-
rescue LoadError => exception
|
75
|
-
raise exception unless exception.path == path
|
76
|
-
end
|
77
|
-
|
78
|
-
begin
|
79
|
-
inflector.constantize(inflector.camelize(path))
|
80
|
-
rescue NameError => exception
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def inflector
|
85
|
-
provider.inflector
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|