frontman-ssg 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +13 -2
  4. data/Rakefile +5 -2
  5. data/frontman-ssg.gemspec +1 -0
  6. data/lib/frontman.rb +0 -5
  7. data/lib/frontman/app.rb +1 -3
  8. data/lib/frontman/builder/file.rb +1 -3
  9. data/lib/frontman/commands/init.rb +2 -3
  10. data/lib/frontman/commands/serve.rb +29 -28
  11. data/lib/frontman/concerns/forward_calls_to_app.rb +1 -1
  12. data/lib/frontman/context.rb +68 -57
  13. data/lib/frontman/data_store.rb +1 -3
  14. data/lib/frontman/iterator.rb +1 -3
  15. data/lib/frontman/renderers/erb_renderer.rb +19 -1
  16. data/lib/frontman/renderers/haml_renderer.rb +29 -1
  17. data/lib/frontman/renderers/renderer_resolver.rb +18 -5
  18. data/lib/frontman/renderers/slim_renderer.rb +30 -0
  19. data/lib/frontman/resource.rb +9 -13
  20. data/lib/frontman/sitemap_tree.rb +1 -3
  21. data/lib/frontman/version.rb +1 -1
  22. data/project-templates/webpack/helpers/assets_helper.rb +1 -3
  23. data/sorbet/rbi/gems/ast.rbi +48 -0
  24. data/sorbet/rbi/gems/better_errors.rbi +180 -0
  25. data/sorbet/rbi/gems/binding_of_caller.rbi +23 -0
  26. data/sorbet/rbi/gems/coderay.rbi +24 -0
  27. data/sorbet/rbi/gems/debug_inspector.rbi +19 -0
  28. data/sorbet/rbi/gems/docile.rbi +32 -0
  29. data/sorbet/rbi/gems/dotenv.rbi +68 -0
  30. data/sorbet/rbi/gems/erubi.rbi +27 -0
  31. data/sorbet/rbi/gems/erubis.rbi +280 -0
  32. data/sorbet/rbi/gems/haml.rbi +521 -0
  33. data/sorbet/rbi/gems/htmlentities.rbi +46 -0
  34. data/sorbet/rbi/gems/jaro_winkler.rbi +15 -0
  35. data/sorbet/rbi/gems/kramdown-parser-gfm.rbi +29 -0
  36. data/sorbet/rbi/gems/kramdown.rbi +338 -0
  37. data/sorbet/rbi/gems/listen.rbi +301 -0
  38. data/sorbet/rbi/gems/mustermann.rbi +481 -0
  39. data/sorbet/rbi/gems/nokogiri.rbi +1011 -0
  40. data/sorbet/rbi/gems/parallel.rbi +82 -0
  41. data/sorbet/rbi/gems/parser.rbi +1405 -0
  42. data/sorbet/rbi/gems/rack-protection.rbi +16 -0
  43. data/sorbet/rbi/gems/rack.rbi +507 -0
  44. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  45. data/sorbet/rbi/gems/rake.rbi +641 -0
  46. data/sorbet/rbi/gems/rexml.rbi +93 -0
  47. data/sorbet/rbi/gems/rouge.rbi +1551 -0
  48. data/sorbet/rbi/gems/rspec-core.rbi +1893 -0
  49. data/sorbet/rbi/gems/rspec-expectations.rbi +1125 -0
  50. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  51. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  52. data/sorbet/rbi/gems/rspec.rbi +15 -0
  53. data/sorbet/rbi/gems/rubocop-performance.rbi +274 -0
  54. data/sorbet/rbi/gems/rubocop.rbi +7403 -0
  55. data/sorbet/rbi/gems/ruby-progressbar.rbi +305 -0
  56. data/sorbet/rbi/gems/ruby2_keywords.rbi +17 -0
  57. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  58. data/sorbet/rbi/gems/simplecov.rbi +405 -0
  59. data/sorbet/rbi/gems/sinatra.rbi +488 -0
  60. data/sorbet/rbi/gems/slim.rbi +144 -0
  61. data/sorbet/rbi/gems/temple.rbi +281 -0
  62. data/sorbet/rbi/gems/thor.rbi +522 -0
  63. data/sorbet/rbi/gems/tilt.rbi +82 -0
  64. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  65. data/sorbet/rbi/gems/yaml-front-matter.rbi +16 -0
  66. data/sorbet/rbi/hidden-definitions/errors.txt +2859 -24228
  67. data/sorbet/rbi/hidden-definitions/hidden.rbi +7111 -40830
  68. data/sorbet/rbi/sorbet-typed/lib/nokogiri/1.10.10/nokogiri.rbi +1615 -0
  69. data/sorbet/rbi/sorbet-typed/lib/thor/all/thor.rbi +905 -0
  70. data/sorbet/rbi/todo.rbi +6 -0
  71. data/spec/frontman/bootstrapper_spec.rb +1 -1
  72. data/spec/frontman/context_spec.rb +45 -6
  73. data/spec/frontman/mocks/context.haml +18 -0
  74. data/spec/frontman/renderers/slim_renderer_spec.rb +12 -0
  75. metadata +66 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d98534ae36366f01f9b304aa66cf452d69688a68e37f33e53a3b0afab9ce328a
4
- data.tar.gz: aa330a04fd43740fff7dfc1ef6d3e46b640a0a428070456933e24141e58d3b86
3
+ metadata.gz: d044410bb8578a36c2876cf887a9e807053864fd28045c1bc92e4ecce769f49b
4
+ data.tar.gz: 0e9400d87ef35ab925d80cc05b4ba9b122ab52d5c280ddb6a39ffb9b9c76c48e
5
5
  SHA512:
6
- metadata.gz: 6e23982fea37d56e567c96d9344efb5f98c02fead828861410ead02486fe7d6520eb47d0d509bfd46f57e20e4e0476c1ee69820779074afa51fb1527f985e71e
7
- data.tar.gz: b1eab4c96e41d2a38951f8893ef29786b20ed2b31689b6c94bfd22a8263f545f9fdd250d3ce8d097fbd694558744c605e92a1d586485376929d2c295520fe335
6
+ metadata.gz: c54550757e0312a3f7e9051a37bb173f98c120f76b75b99b7634383ba687e5977dfd0bf8c82ecacfecf28e998742aa9c3459172086c734fba3287b1868176d4e
7
+ data.tar.gz: b89cf82a4807cd97ce05e2a569afe1b6a92266d2aca5c942c68ba5360ac8ecf1419400526fd3955e9575670f48d3b5b57dd177117daf5fe1da8703faf36cb1ee
@@ -32,6 +32,7 @@ Metrics/MethodLength:
32
32
 
33
33
  Metrics/AbcSize:
34
34
  Exclude:
35
+ - 'lib/frontman/context.rb'
35
36
  - 'lib/frontman/sitemap_tree.rb'
36
37
  - 'lib/frontman/data_store.rb'
37
38
  - 'lib/frontman/builder/statistics_collector.rb'
@@ -73,9 +74,11 @@ Metrics/BlockLength:
73
74
  - '*.gemspec'
74
75
 
75
76
  Metrics/LineLength:
77
+ Max: 100
76
78
  Exclude:
77
79
  - 'frontman-ssg.gemspec'
78
80
  - 'spec/**/*'
81
+ - 'lib/frontman/context.rb'
79
82
 
80
83
  Naming/FileName:
81
84
  Exclude:
@@ -5,9 +5,20 @@ We document all notable changes to the project in the file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [semantic versioning](http://semver.org/).
6
6
 
7
7
  # Release Notes
8
- ## [Unreleased](https://github.com/algolia/frontman/compare/0.0.4...master)
8
+ ## [Unreleased](https://github.com/algolia/frontman/compare/0.1.0...master)
9
9
 
10
- ## [0.0.4](https://github.com/algolia/frontman/tree/0.0.3) - 2020-08-28
10
+ ## [0.1.0](https://github.com/algolia/frontman/tree/0.1.0) - 2021-01-05
11
+
12
+ ### Added
13
+ * Support for Slim templates ([`#41`](https://github.com/algolia/frontman/pull/41)) by [@westonganger](https://github.com/westonganger)
14
+ * `append_content` method to push content to a block ([`#25`](https://github.com/algolia/frontman/pull/25)) by [@westonganger](https://github.com/westonganger)
15
+ * Setting to change the local server host ([`#36`](https://github.com/algolia/frontman/pull/36)) by [@westonganger](https://github.com/westonganger)
16
+ * Execute Rubocop in the default Rake task ([`#37`](https://github.com/algolia/frontman/pull/37)) by [@westonganger](https://github.com/westonganger)
17
+
18
+ ### Fixed
19
+ * Issue with setting for local server ports ([`#42`](https://github.com/algolia/frontman/pull/42)) by [@westonganger](https://github.com/westonganger)
20
+
21
+ ## [0.0.4](https://github.com/algolia/frontman/tree/0.0.4) - 2020-08-28
11
22
 
12
23
  ### Added
13
24
  * Retry strategy to allow for multiple running Frontman processes ([`#24`](https://github.com/algolia/frontman/pull/24)) by [@westonganger](https://github.com/westonganger)
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require 'bundler/gem_tasks'
4
4
  require 'frontman/version'
5
5
  require 'rake'
6
6
  require 'rspec/core/rake_task'
7
+ require 'rubocop/rake_task'
7
8
 
8
9
  begin
9
10
  Bundler.setup(:default, :development)
@@ -15,7 +16,9 @@ end
15
16
 
16
17
  RSpec::Core::RakeTask.new(:spec)
17
18
 
18
- task default: :spec
19
+ RuboCop::RakeTask.new(:rubocop)
20
+
21
+ task default: [:spec, :rubocop]
19
22
 
20
23
  namespace :frontman do
21
24
  GEM_VERSION_FILE = File.join(Dir.pwd, 'lib/frontman/version.rb')
@@ -91,4 +94,4 @@ module Bundler
91
94
  version.to_s
92
95
  end
93
96
  end
94
- end
97
+ end
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_runtime_dependency 'parallel', '~> 1.17'
43
43
  s.add_runtime_dependency 'rouge', '~> 3.16'
44
44
  s.add_runtime_dependency 'sinatra', '~> 2.0'
45
+ s.add_runtime_dependency 'slim', '~> 4.1'
45
46
  s.add_runtime_dependency 'sorbet-runtime', '~> 0.5'
46
47
  s.add_runtime_dependency 'thor', '~> 0.20'
47
48
  s.add_runtime_dependency 'yaml-front-matter', '0.0.1'
@@ -10,8 +10,3 @@ require 'frontman/data_store_file'
10
10
  require 'frontman/errors'
11
11
  require 'frontman/sitemap_tree'
12
12
  require 'frontman/resource'
13
-
14
- require 'frontman/renderers/renderer'
15
- require 'frontman/renderers/erb_renderer'
16
- require 'frontman/renderers/haml_renderer'
17
- require 'frontman/renderers/markdown_renderer'
@@ -97,9 +97,7 @@ module Frontman
97
97
 
98
98
  sig { params(dirs: T.any(Array, Hash)).void }
99
99
  def register_data_dirs(dirs)
100
- if dirs.is_a?(Array)
101
- dirs = dirs.map { |dir| [dir.split('/').last, dir] }.to_h
102
- end
100
+ dirs = dirs.map { |dir| [dir.split('/').last, dir] }.to_h if dirs.is_a?(Array)
103
101
 
104
102
  dirs.each do |name, dir|
105
103
  define_singleton_method name do
@@ -12,9 +12,7 @@ module Frontman
12
12
 
13
13
  sig { params(path: String, status: T.any(String, Symbol)).void }
14
14
  def initialize(path, status)
15
- unless valid_status?(status)
16
- raise "#{status} is not a valid file status!"
17
- end
15
+ raise "#{status} is not a valid file status!" unless valid_status?(status)
18
16
 
19
17
  @path = path
20
18
  @status = status.to_sym
@@ -10,9 +10,8 @@ module Frontman
10
10
  desc 'init', 'Bootstrap a new Frontman project'
11
11
  def init(path)
12
12
  template = options[:template] || 'default'
13
- unless template_exists?(template)
14
- raise "Template #{template} does not exist!"
15
- end
13
+
14
+ raise "Template #{template} does not exist!" unless template_exists?(template)
16
15
 
17
16
  target_dir = File.join(Dir.pwd, path == '.' ? '' : path)
18
17
 
@@ -75,44 +75,45 @@ module Frontman
75
75
  FrontmanServer.set :public_folder, Frontman::Config.get(
76
76
  :public_dir, fallback: 'public'
77
77
  )
78
- FrontmanServer.run! do
79
- host = "http://localhost:#{FrontmanServer.settings.port}"
80
- print "== View your site at \"#{host}/\"\n"
81
- processes += assets_pipeline.run_in_background!(:after)
82
- at_exit { processes.each { |pid| Process.kill(0, pid) } }
83
- end
84
- end
85
- end
86
- end
87
-
88
- class FrontmanServer < Sinatra::Base
89
- port = Frontman::Config.get(:port, fallback: 4568)
90
- num_retries = Frontman::Config.get(:port_retries, fallback: 3)
91
78
 
92
- retry_strategy = Frontman::Config.get(:port_retry_strategy, fallback: ->(p) {
93
- port_in_use = false
79
+ port = Frontman::Config.get(:port, fallback: 4568)
80
+ num_retries = Frontman::Config.get(:port_retries, fallback: 3)
94
81
 
95
- (1 + num_retries).times do
96
- begin
97
- port_in_use = Socket.tcp('localhost', p, connect_timeout: 3) { true }
98
- rescue StandardError
82
+ port_retry_strategy = Frontman::Config.get(:port_retry_strategy, fallback: ->(p) {
99
83
  port_in_use = false
100
- end
101
84
 
102
- break unless port_in_use
85
+ (1 + num_retries).times do
86
+ begin
87
+ port_in_use = Socket.tcp('localhost', p, connect_timeout: 3) { true }
88
+ rescue StandardError
89
+ port_in_use = false
90
+ end
103
91
 
104
- p += 1
105
- end
92
+ break unless port_in_use
93
+
94
+ p += 1
95
+ end
106
96
 
107
- raise Frontman::ServerPortError if port_in_use
97
+ raise Frontman::ServerPortError if port_in_use
108
98
 
109
- p
110
- })
99
+ p
100
+ })
111
101
 
112
- port = retry_strategy.call(port)
102
+ FrontmanServer.set(:port, port_retry_strategy.call(port))
103
+ FrontmanServer.set(:bind, Frontman::Config.get(:host, fallback: 'localhost'))
113
104
 
114
- set :port, port
105
+ FrontmanServer.run! do
106
+ hostname = FrontmanServer.settings.bind
107
+ host = "http://#{hostname}:#{FrontmanServer.settings.port}"
108
+ print "== View your site at \"#{host}/\"\n"
109
+ processes += assets_pipeline.run_in_background!(:after)
110
+ at_exit { processes.each { |pid| Process.kill(0, pid) } }
111
+ end
112
+ end
113
+ end
114
+ end
115
115
 
116
+ class FrontmanServer < Sinatra::Base
116
117
  set :server_settings,
117
118
  # Avoid having webrick displaying logs for every requests to the serve
118
119
  AccessLog: [],
@@ -1,4 +1,4 @@
1
- # typed: true
1
+ # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Frontman
@@ -11,55 +11,55 @@ module Frontman
11
11
  extend T::Sig
12
12
  include Frontman::ForwardCallsToApp
13
13
 
14
- sig { params(layout: String).returns(String) }
15
- def wrap_layout(layout)
14
+ sig { params(layout: String, block: T.proc.void).returns(String) }
15
+ def wrap_layout(layout, &block)
16
16
  layout_dir = Frontman::Config.get(:layout_dir, fallback: 'views/layouts')
17
17
  layout_path = File.join(layout_dir, layout)
18
18
 
19
- # Haml is not designed to do handle wrap_layout properly
20
- # so we need to hack the buffer of haml that is set
21
- # inside the context by haml
22
- save_buffer
23
-
24
- # We don't save the content of the yield, it will be saved in the buffer
25
- yield
26
-
27
- # The buffer now contains the content of the yield
28
- content = load_buffer
29
-
30
- # Restore the buffer so the rendering of the file can continue
31
- restore_buffer
19
+ content = get_content_buffer(nil, &block)
32
20
 
33
21
  Resource.from_path(layout_path, nil, false).render(content)
34
22
  end
35
23
 
36
24
  sig do
37
- params(key: T.any(String, Symbol), content: T.untyped)
38
- .returns(T.untyped)
25
+ params(
26
+ key: T.any(String, Symbol),
27
+ content: T.untyped,
28
+ block: T.nilable(T.proc.void)
29
+ ).returns(T.untyped)
39
30
  end
40
- def content_for(key, content = nil)
41
- # Haml is not designed to do handle content_for properly
42
- # so we need to hack the buffer of haml that is set
43
- # inside the context by haml
44
- save_buffer
45
-
46
- content ||= ''
47
-
48
- if block_given?
49
- # We don't save the content of the yield, it will be saved in the buffer
50
- yield
31
+ def content_for(key, content = nil, &block)
32
+ content = get_content_buffer(content, &(block if block_given?))
51
33
 
52
- # The buffer now contains the content of the yield
53
- content = load_buffer
54
- end
34
+ # We store the the content block inside the current page
35
+ # because we don't know which renderer/layout/template will need it
36
+ current_page = Frontman::App.instance.current_page
37
+ current_page.content_blocks[key.to_sym] = content unless current_page.nil?
38
+ end
55
39
 
56
- # Restore the buffer so the rendering of the file can continue
57
- restore_buffer
40
+ sig do
41
+ params(
42
+ key: T.any(String, Symbol),
43
+ content: T.untyped,
44
+ block: T.nilable(T.proc.void)
45
+ ).returns(T.untyped)
46
+ end
47
+ def append_content(key, content = nil, &block)
48
+ content = get_content_buffer(content, &(block if block_given?))
58
49
 
59
50
  # We store the the content block inside the current page
60
51
  # because we don't know which renderer/layout/template will need it
61
52
  current_page = Frontman::App.instance.current_page
62
- current_page.content_blocks[key.to_sym] = content unless current_page.nil?
53
+
54
+ return if current_page.nil?
55
+
56
+ key = key.to_sym
57
+ current_page.content_blocks[key] ||= ''
58
+ if current_page.content_blocks[key].frozen?
59
+ current_page.content_blocks[key] = current_page.content_blocks[key].dup
60
+ end
61
+
62
+ current_page.content_blocks[key].concat(content)
63
63
  end
64
64
 
65
65
  sig { params(key: T.any(String, Symbol)).returns(T::Boolean) }
@@ -83,43 +83,54 @@ module Frontman
83
83
 
84
84
  private
85
85
 
86
+ def renderers
87
+ @renderers ||= RendererResolver.instance.all_renderers
88
+ end
89
+
86
90
  sig { void }
87
91
  def save_buffer
88
- haml_locals = instance_variable_get(:@_haml_locals)
89
-
90
- if haml_locals
91
- # save buffer
92
- @buffer = haml_locals[:_hamlout].buffer
93
- # empty the buffer so we can capture everything from the new render
94
- haml_locals[:_hamlout].buffer = ''
95
- else
96
- # save buffer
97
- @buffer = instance_variable_get(:@_erbout)
98
- # empty the buffer so we can capture everything from the new render
99
- instance_variable_set(:@_erbout, '')
92
+ renderers.each do |_, renderer|
93
+ renderer.save_buffer(self) if renderer.respond_to?(:save_buffer)
100
94
  end
101
95
  end
102
96
 
103
97
  sig { void }
104
98
  def restore_buffer
105
- haml_locals = instance_variable_get(:@_haml_locals)
106
-
107
- if haml_locals
108
- haml_locals[:_hamlout].buffer = @buffer
109
- else
110
- instance_variable_set(:@_erbout, @buffer)
99
+ renderers.each do |_, renderer|
100
+ renderer.restore_buffer(self) if renderer.respond_to?(:restore_buffer)
111
101
  end
112
102
  end
113
103
 
114
104
  sig { returns(T.untyped) }
115
105
  def load_buffer
116
- haml_locals = instance_variable_get(:@_haml_locals)
106
+ renderers.each do |_, renderer|
107
+ content = renderer.load_buffer(self) if renderer.respond_to?(:load_buffer)
108
+ return content if content
109
+ end
110
+
111
+ nil
112
+ end
117
113
 
118
- if haml_locals
119
- haml_locals[:_hamlout].buffer
120
- else
121
- instance_variable_get(:@_erbout)
114
+ sig { params(content: T.untyped).returns(String) }
115
+ def get_content_buffer(content)
116
+ # Haml is not designed to do handle wrap_layout properly so we need to
117
+ # hack the buffer of haml that is set inside the context by haml
118
+ save_buffer
119
+
120
+ content ||= ''
121
+
122
+ if block_given?
123
+ # We don't save the content of the yield, it will be saved in the buffer
124
+ rendered_content = yield
125
+
126
+ # The buffer now contains the content of the yield when rendering HAML
127
+ content = load_buffer || rendered_content
122
128
  end
129
+
130
+ # Restore the buffer so the rendering of the file can continue
131
+ restore_buffer
132
+
133
+ content
123
134
  end
124
135
  end
125
136
  end
@@ -60,9 +60,7 @@ module Frontman
60
60
  end
61
61
 
62
62
  # Make sure we forward the access to the data
63
- if @cache.respond_to?(method_name)
64
- return @cache.public_send(method_name, &block)
65
- end
63
+ return @cache.public_send(method_name, &block) if @cache.respond_to?(method_name)
66
64
 
67
65
  nil
68
66
  end
@@ -35,9 +35,7 @@ module Frontman
35
35
  end
36
36
 
37
37
  def forward(method, collection, *options, &block)
38
- if parallel?
39
- return ::Parallel.public_send(method, collection, *options, &block)
40
- end
38
+ return ::Parallel.public_send(method, collection, *options, &block) if parallel?
41
39
 
42
40
  collection.public_send(method, &block)
43
41
  end
@@ -1,5 +1,5 @@
1
1
  # typed: false
2
- # frozen_string_literal: true
2
+ # frozen_string_literal: false
3
3
 
4
4
  require 'erubis'
5
5
  require 'frontman/renderers/renderer'
@@ -17,5 +17,23 @@ module Frontman
17
17
 
18
18
  compiled.result(scope.get_binding { content })
19
19
  end
20
+
21
+ def save_buffer(context)
22
+ buffer = context.instance_variable_get(:@_erbout)
23
+
24
+ return unless buffer
25
+
26
+ @buffer = buffer
27
+ context.instance_variable_set(:@_erbout, '')
28
+ end
29
+
30
+ def restore_buffer(context)
31
+ context.instance_variable_set(:@_erbout, @buffer) if @buffer
32
+ @buffer = nil
33
+ end
34
+
35
+ def load_buffer(context)
36
+ context.instance_variable_get(:@_erbout)
37
+ end
20
38
  end
21
39
  end
@@ -1,5 +1,5 @@
1
1
  # typed: false
2
- # frozen_string_literal: true
2
+ # frozen_string_literal: false
3
3
 
4
4
  require 'haml'
5
5
  require 'frontman/renderers/renderer'
@@ -18,5 +18,33 @@ module Frontman
18
18
  def render_content(compiled, content, scope, _data)
19
19
  compiled.render(scope.get_binding) { content }
20
20
  end
21
+
22
+ def load_buffer(context)
23
+ haml_locals = context.instance_variable_get(:@_haml_locals)
24
+
25
+ haml_locals[:_hamlout].buffer if haml_locals
26
+ end
27
+
28
+ def save_buffer(context)
29
+ @buffer = nil
30
+ haml_locals = context.instance_variable_get(:@_haml_locals)
31
+
32
+ return unless haml_locals
33
+
34
+ @buffer = haml_locals[:_hamlout].buffer
35
+ # empty the buffer so we can capture everything from the new render
36
+ haml_locals[:_hamlout].buffer = ''
37
+ context.instance_variable_set(:@_haml_locals, haml_locals)
38
+ end
39
+
40
+ def restore_buffer(context)
41
+ haml_locals = context.instance_variable_get(:@_haml_locals)
42
+
43
+ return unless haml_locals
44
+
45
+ haml_locals[:_hamlout].buffer = @buffer
46
+ context.instance_variable_set(:@_haml_locals, haml_locals)
47
+ @buffer = nil
48
+ end
21
49
  end
22
50
  end