frontman-ssg 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +13 -2
- data/Rakefile +5 -2
- data/frontman-ssg.gemspec +1 -0
- data/lib/frontman.rb +0 -5
- data/lib/frontman/app.rb +1 -3
- data/lib/frontman/builder/file.rb +1 -3
- data/lib/frontman/commands/init.rb +2 -3
- data/lib/frontman/commands/serve.rb +29 -28
- data/lib/frontman/concerns/forward_calls_to_app.rb +1 -1
- data/lib/frontman/context.rb +68 -57
- data/lib/frontman/data_store.rb +1 -3
- data/lib/frontman/iterator.rb +1 -3
- data/lib/frontman/renderers/erb_renderer.rb +19 -1
- data/lib/frontman/renderers/haml_renderer.rb +29 -1
- data/lib/frontman/renderers/renderer_resolver.rb +18 -5
- data/lib/frontman/renderers/slim_renderer.rb +30 -0
- data/lib/frontman/resource.rb +9 -13
- data/lib/frontman/sitemap_tree.rb +1 -3
- data/lib/frontman/version.rb +1 -1
- data/project-templates/webpack/helpers/assets_helper.rb +1 -3
- data/sorbet/rbi/gems/ast.rbi +48 -0
- data/sorbet/rbi/gems/better_errors.rbi +180 -0
- data/sorbet/rbi/gems/binding_of_caller.rbi +23 -0
- data/sorbet/rbi/gems/coderay.rbi +24 -0
- data/sorbet/rbi/gems/debug_inspector.rbi +19 -0
- data/sorbet/rbi/gems/docile.rbi +32 -0
- data/sorbet/rbi/gems/dotenv.rbi +68 -0
- data/sorbet/rbi/gems/erubi.rbi +27 -0
- data/sorbet/rbi/gems/erubis.rbi +280 -0
- data/sorbet/rbi/gems/haml.rbi +521 -0
- data/sorbet/rbi/gems/htmlentities.rbi +46 -0
- data/sorbet/rbi/gems/jaro_winkler.rbi +15 -0
- data/sorbet/rbi/gems/kramdown-parser-gfm.rbi +29 -0
- data/sorbet/rbi/gems/kramdown.rbi +338 -0
- data/sorbet/rbi/gems/listen.rbi +301 -0
- data/sorbet/rbi/gems/mustermann.rbi +481 -0
- data/sorbet/rbi/gems/nokogiri.rbi +1011 -0
- data/sorbet/rbi/gems/parallel.rbi +82 -0
- data/sorbet/rbi/gems/parser.rbi +1405 -0
- data/sorbet/rbi/gems/rack-protection.rbi +16 -0
- data/sorbet/rbi/gems/rack.rbi +507 -0
- data/sorbet/rbi/gems/rainbow.rbi +118 -0
- data/sorbet/rbi/gems/rake.rbi +641 -0
- data/sorbet/rbi/gems/rexml.rbi +93 -0
- data/sorbet/rbi/gems/rouge.rbi +1551 -0
- data/sorbet/rbi/gems/rspec-core.rbi +1893 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +1125 -0
- data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
- data/sorbet/rbi/gems/rspec-support.rbi +280 -0
- data/sorbet/rbi/gems/rspec.rbi +15 -0
- data/sorbet/rbi/gems/rubocop-performance.rbi +274 -0
- data/sorbet/rbi/gems/rubocop.rbi +7403 -0
- data/sorbet/rbi/gems/ruby-progressbar.rbi +305 -0
- data/sorbet/rbi/gems/ruby2_keywords.rbi +17 -0
- data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
- data/sorbet/rbi/gems/simplecov.rbi +405 -0
- data/sorbet/rbi/gems/sinatra.rbi +488 -0
- data/sorbet/rbi/gems/slim.rbi +144 -0
- data/sorbet/rbi/gems/temple.rbi +281 -0
- data/sorbet/rbi/gems/thor.rbi +522 -0
- data/sorbet/rbi/gems/tilt.rbi +82 -0
- data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
- data/sorbet/rbi/gems/yaml-front-matter.rbi +16 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +2859 -24228
- data/sorbet/rbi/hidden-definitions/hidden.rbi +7111 -40830
- data/sorbet/rbi/sorbet-typed/lib/nokogiri/1.10.10/nokogiri.rbi +1615 -0
- data/sorbet/rbi/sorbet-typed/lib/thor/all/thor.rbi +905 -0
- data/sorbet/rbi/todo.rbi +6 -0
- data/spec/frontman/bootstrapper_spec.rb +1 -1
- data/spec/frontman/context_spec.rb +45 -6
- data/spec/frontman/mocks/context.haml +18 -0
- data/spec/frontman/renderers/slim_renderer_spec.rb +12 -0
- metadata +66 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d044410bb8578a36c2876cf887a9e807053864fd28045c1bc92e4ecce769f49b
|
4
|
+
data.tar.gz: 0e9400d87ef35ab925d80cc05b4ba9b122ab52d5c280ddb6a39ffb9b9c76c48e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54550757e0312a3f7e9051a37bb173f98c120f76b75b99b7634383ba687e5977dfd0bf8c82ecacfecf28e998742aa9c3459172086c734fba3287b1868176d4e
|
7
|
+
data.tar.gz: b89cf82a4807cd97ce05e2a569afe1b6a92266d2aca5c942c68ba5360ac8ecf1419400526fd3955e9575670f48d3b5b57dd177117daf5fe1da8703faf36cb1ee
|
data/.rubocop.yml
CHANGED
@@ -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:
|
data/CHANGELOG.md
CHANGED
@@ -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
|
8
|
+
## [Unreleased](https://github.com/algolia/frontman/compare/0.1.0...master)
|
9
9
|
|
10
|
-
## [0.0
|
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
|
-
|
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
|
data/frontman-ssg.gemspec
CHANGED
@@ -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'
|
data/lib/frontman.rb
CHANGED
@@ -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'
|
data/lib/frontman/app.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
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
|
-
|
93
|
-
|
79
|
+
port = Frontman::Config.get(:port, fallback: 4568)
|
80
|
+
num_retries = Frontman::Config.get(:port_retries, fallback: 3)
|
94
81
|
|
95
|
-
|
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
|
-
|
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
|
-
|
105
|
-
|
92
|
+
break unless port_in_use
|
93
|
+
|
94
|
+
p += 1
|
95
|
+
end
|
106
96
|
|
107
|
-
|
97
|
+
raise Frontman::ServerPortError if port_in_use
|
108
98
|
|
109
|
-
|
110
|
-
|
99
|
+
p
|
100
|
+
})
|
111
101
|
|
112
|
-
|
102
|
+
FrontmanServer.set(:port, port_retry_strategy.call(port))
|
103
|
+
FrontmanServer.set(:bind, Frontman::Config.get(:host, fallback: 'localhost'))
|
113
104
|
|
114
|
-
|
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: [],
|
data/lib/frontman/context.rb
CHANGED
@@ -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
|
-
|
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(
|
38
|
-
.
|
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
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
57
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
data/lib/frontman/data_store.rb
CHANGED
@@ -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
|
data/lib/frontman/iterator.rb
CHANGED
@@ -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:
|
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:
|
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
|