hanami-view 1.3.0.beta1 → 2.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/LICENSE +20 -0
  4. data/README.md +20 -862
  5. data/hanami-view.gemspec +26 -16
  6. data/lib/hanami-view.rb +3 -1
  7. data/lib/hanami/view.rb +208 -223
  8. data/lib/hanami/view/application_configuration.rb +77 -0
  9. data/lib/hanami/view/application_context.rb +35 -0
  10. data/lib/hanami/view/application_view.rb +89 -0
  11. data/lib/hanami/view/context.rb +97 -0
  12. data/lib/hanami/view/context_helpers/content_helpers.rb +26 -0
  13. data/lib/hanami/view/decorated_attributes.rb +82 -0
  14. data/lib/hanami/view/errors.rb +19 -56
  15. data/lib/hanami/view/exposure.rb +126 -0
  16. data/lib/hanami/view/exposures.rb +74 -0
  17. data/lib/hanami/view/part.rb +217 -0
  18. data/lib/hanami/view/part_builder.rb +140 -0
  19. data/lib/hanami/view/path.rb +68 -0
  20. data/lib/hanami/view/render_environment.rb +62 -0
  21. data/lib/hanami/view/render_environment_missing.rb +44 -0
  22. data/lib/hanami/view/rendered.rb +55 -0
  23. data/lib/hanami/view/renderer.rb +79 -0
  24. data/lib/hanami/view/scope.rb +189 -0
  25. data/lib/hanami/view/scope_builder.rb +98 -0
  26. data/lib/hanami/view/standalone_view.rb +396 -0
  27. data/lib/hanami/view/tilt.rb +78 -0
  28. data/lib/hanami/view/tilt/erb.rb +26 -0
  29. data/lib/hanami/view/tilt/erbse.rb +21 -0
  30. data/lib/hanami/view/tilt/haml.rb +26 -0
  31. data/lib/hanami/view/version.rb +5 -5
  32. metadata +113 -63
  33. data/LICENSE.md +0 -22
  34. data/lib/hanami/layout.rb +0 -172
  35. data/lib/hanami/presenter.rb +0 -98
  36. data/lib/hanami/view/configuration.rb +0 -504
  37. data/lib/hanami/view/dsl.rb +0 -347
  38. data/lib/hanami/view/escape.rb +0 -225
  39. data/lib/hanami/view/inheritable.rb +0 -54
  40. data/lib/hanami/view/rendering.rb +0 -294
  41. data/lib/hanami/view/rendering/layout_finder.rb +0 -128
  42. data/lib/hanami/view/rendering/layout_registry.rb +0 -69
  43. data/lib/hanami/view/rendering/layout_scope.rb +0 -274
  44. data/lib/hanami/view/rendering/null_layout.rb +0 -52
  45. data/lib/hanami/view/rendering/null_local.rb +0 -82
  46. data/lib/hanami/view/rendering/null_template.rb +0 -83
  47. data/lib/hanami/view/rendering/options.rb +0 -24
  48. data/lib/hanami/view/rendering/partial.rb +0 -31
  49. data/lib/hanami/view/rendering/partial_file.rb +0 -29
  50. data/lib/hanami/view/rendering/partial_finder.rb +0 -75
  51. data/lib/hanami/view/rendering/partial_templates_finder.rb +0 -73
  52. data/lib/hanami/view/rendering/registry.rb +0 -134
  53. data/lib/hanami/view/rendering/scope.rb +0 -108
  54. data/lib/hanami/view/rendering/subscope.rb +0 -56
  55. data/lib/hanami/view/rendering/template.rb +0 -69
  56. data/lib/hanami/view/rendering/template_finder.rb +0 -55
  57. data/lib/hanami/view/rendering/template_name.rb +0 -50
  58. data/lib/hanami/view/rendering/templates_finder.rb +0 -144
  59. data/lib/hanami/view/rendering/view_finder.rb +0 -37
  60. data/lib/hanami/view/template.rb +0 -57
@@ -1,37 +0,0 @@
1
- module Hanami
2
- module View
3
- module Rendering
4
- # Find a view
5
- #
6
- # @api private
7
- # @since 0.1.0
8
- #
9
- # @see Hanami::View::Rendering::Registry
10
- class ViewFinder
11
- # Initialize a finder
12
- #
13
- # @param view [Class] the superclass view
14
- #
15
- # @api private
16
- # @since 0.1.0
17
- def initialize(view)
18
- @view = view
19
- end
20
-
21
- # Find a view for the given template.
22
- # It looks up for the current view and its subclasses.
23
- #
24
- # @param template [Hanami::View::Template] a template to be associated
25
- # to a view
26
- #
27
- # @return [Class] a view associated with the given template
28
- #
29
- # @api private
30
- # @since 0.1.0
31
- def find(template)
32
- @view.subclasses.find {|v| v.format == template.format } || @view
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,57 +0,0 @@
1
- require 'tilt'
2
-
3
- module Hanami
4
- module View
5
- # A logic-less template.
6
- #
7
- # @since 0.1.0
8
- class Template
9
- def initialize(template, encoding = Encoding::UTF_8)
10
- options = { default_encoding: encoding }
11
-
12
- if slim?(template)
13
- # NOTE disable_escape: true is for Slim compatibility
14
- # See https://github.com/hanami/assets/issues/36
15
- options[:disable_escape] = true
16
- end
17
-
18
- @_template = Tilt.new(template, nil, options)
19
- end
20
-
21
- # Returns the format that the template handles.
22
- #
23
- # @return [Symbol] the format name
24
- #
25
- # @since 0.1.0
26
- #
27
- # @example
28
- # require 'hanami/view'
29
- #
30
- # template = Hanami::View::Template.new('index.html.erb')
31
- # template.format # => :html
32
- def format
33
- @_template.basename.match(/\.([^.]+)/).captures.first.to_sym
34
- end
35
-
36
- # Render the template within the context of the given scope.
37
- #
38
- # @param scope [Hanami::View::Scope] the rendering scope
39
- #
40
- # @return [String] the output of the rendering process
41
- #
42
- # @api private
43
- # @since 0.1.0
44
- #
45
- # @see Hanami::View::Scope
46
- def render(scope, &blk)
47
- @_template.render(scope, {}, &blk)
48
- end
49
-
50
- private
51
-
52
- def slim?(template)
53
- File.extname(template) == ".slim".freeze
54
- end
55
- end
56
- end
57
- end