bridgetown-core 0.15.0.beta4 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -0
  3. data/bridgetown-core.gemspec +3 -1
  4. data/lib/bridgetown-core.rb +7 -1
  5. data/lib/bridgetown-core/commands/concerns/actions.rb +2 -1
  6. data/lib/bridgetown-core/commands/console.rb +4 -4
  7. data/lib/bridgetown-core/concerns/data_accessible.rb +19 -0
  8. data/lib/bridgetown-core/concerns/layout_placeable.rb +17 -0
  9. data/lib/bridgetown-core/concerns/liquid_renderable.rb +20 -0
  10. data/lib/bridgetown-core/concerns/publishable.rb +10 -0
  11. data/lib/bridgetown-core/concerns/site/configurable.rb +66 -31
  12. data/lib/bridgetown-core/concerns/site/content.rb +88 -29
  13. data/lib/bridgetown-core/concerns/site/extensible.rb +15 -12
  14. data/lib/bridgetown-core/concerns/site/localizable.rb +20 -0
  15. data/lib/bridgetown-core/concerns/site/processable.rb +12 -10
  16. data/lib/bridgetown-core/concerns/site/renderable.rb +21 -2
  17. data/lib/bridgetown-core/concerns/site/writable.rb +16 -2
  18. data/lib/bridgetown-core/concerns/validatable.rb +59 -0
  19. data/lib/bridgetown-core/configuration.rb +5 -2
  20. data/lib/bridgetown-core/converter.rb +34 -0
  21. data/lib/bridgetown-core/converters/erb_templates.rb +78 -0
  22. data/lib/bridgetown-core/converters/markdown.rb +6 -23
  23. data/lib/bridgetown-core/converters/smartypants.rb +0 -10
  24. data/lib/bridgetown-core/document.rb +8 -52
  25. data/lib/bridgetown-core/drops/site_drop.rb +1 -1
  26. data/lib/bridgetown-core/errors.rb +2 -0
  27. data/lib/bridgetown-core/excerpt.rb +1 -6
  28. data/lib/bridgetown-core/filters.rb +3 -48
  29. data/lib/bridgetown-core/filters/condition_helpers.rb +56 -0
  30. data/lib/bridgetown-core/frontmatter_defaults.rb +17 -0
  31. data/lib/bridgetown-core/layout.rb +24 -1
  32. data/lib/bridgetown-core/liquid_renderer/file_system.rb +1 -1
  33. data/lib/bridgetown-core/page.rb +33 -24
  34. data/lib/bridgetown-core/plugin_manager.rb +10 -2
  35. data/lib/bridgetown-core/reader.rb +1 -0
  36. data/lib/bridgetown-core/readers/collection_reader.rb +1 -0
  37. data/lib/bridgetown-core/readers/data_reader.rb +1 -0
  38. data/lib/bridgetown-core/readers/defaults_reader.rb +27 -0
  39. data/lib/bridgetown-core/readers/layout_reader.rb +1 -0
  40. data/lib/bridgetown-core/readers/page_reader.rb +1 -0
  41. data/lib/bridgetown-core/readers/post_reader.rb +1 -0
  42. data/lib/bridgetown-core/readers/static_file_reader.rb +1 -0
  43. data/lib/bridgetown-core/regenerator.rb +1 -1
  44. data/lib/bridgetown-core/renderer.rb +38 -12
  45. data/lib/bridgetown-core/ruby_template_view.rb +102 -0
  46. data/lib/bridgetown-core/site.rb +2 -0
  47. data/lib/bridgetown-core/tags/class_map.rb +90 -0
  48. data/lib/bridgetown-core/tags/find.rb +86 -0
  49. data/lib/bridgetown-core/tags/t.rb +14 -0
  50. data/lib/bridgetown-core/tags/webpack_path.rb +19 -22
  51. data/lib/bridgetown-core/utils.rb +55 -2
  52. data/lib/bridgetown-core/version.rb +2 -2
  53. data/lib/site_template/src/_layouts/{default.html → default.liquid} +0 -0
  54. data/lib/site_template/src/_layouts/{home.html → home.liquid} +0 -0
  55. data/lib/site_template/src/_layouts/{page.html → page.liquid} +0 -0
  56. data/lib/site_template/src/_layouts/{post.html → post.liquid} +0 -0
  57. metadata +50 -10
  58. data/lib/bridgetown-core/concerns/convertible.rb +0 -235
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Tags
5
+ class TranslationTag < Liquid::Tag
6
+ def render(_context)
7
+ key = @markup.strip
8
+ I18n.t(key)
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ Liquid::Template.register_tag("t", Bridgetown::Tags::TranslationTag)
@@ -2,38 +2,35 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Tags
5
+ # A helper class to help find the path to webpack asset inside of a webpack
6
+ # manifest file.
5
7
  class WebpackPath < Liquid::Tag
6
- include Bridgetown::Filters::URLFilters
7
-
8
- def initialize(tag_name, asset_type, tokens)
8
+ # @param tag_name [String] Name of the tag
9
+ # @param asset_type [String] The type of asset to parse (js, css)
10
+ # @param options [Hash] An options hash
11
+ # @return [void]
12
+ # @see {https://www.rdoc.info/github/Shopify/liquid/Liquid/Tag#initialize-instance_method}
13
+ def initialize(tag_name, asset_type, options)
9
14
  super
10
15
 
11
16
  # js or css
12
17
  @asset_type = asset_type.strip
13
18
  end
14
19
 
20
+ # Render an asset path based on the Webpack manifest file
21
+ # @param context [Liquid::Context] Context passed to the tag
22
+ #
23
+ # @return [String] Returns "MISSING_WEBPACK_MANIFEST" if the manifest
24
+ # file isn't found
25
+ # @return [String] Returns a blank string if the asset isn't found
26
+ # @return [String] Returns the path to the asset if no issues parsing
27
+ #
28
+ # @raise [WebpackAssetError] if unable to find css or js in the manifest
29
+ # file
15
30
  def render(context)
16
31
  @context = context
17
32
  site = context.registers[:site]
18
-
19
- frontend_path = relative_url("_bridgetown/static")
20
-
21
- manifest_file = site.in_root_dir(".bridgetown-webpack", "manifest.json")
22
- if File.exist?(manifest_file)
23
- manifest = JSON.parse(File.read(manifest_file))
24
- if @asset_type == "js"
25
- js_path = manifest["main.js"].split("/").last
26
- [frontend_path, "js", js_path].join("/")
27
- elsif @asset_type == "css"
28
- css_path = manifest["main.css"].split("/").last
29
- [frontend_path, "css", css_path].join("/")
30
- else
31
- Bridgetown.logger.error("Unknown Webpack asset type", @asset_type)
32
- nil
33
- end
34
- else
35
- "MISSING_WEBPACK_MANIFEST"
36
- end
33
+ Bridgetown::Utils.parse_webpack_manifest_file(site, @asset_type) || ""
37
34
  end
38
35
  end
39
36
  end
@@ -14,8 +14,8 @@ module Bridgetown
14
14
  # Constants for use in #slugify
15
15
  SLUGIFY_MODES = %w(raw default pretty simple ascii latin).freeze
16
16
  SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
17
- SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^[:alnum:]]+").freeze
18
- SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
17
+ SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze
18
+ SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze
19
19
  SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
20
20
 
21
21
  # Takes a slug and turns it into a simple title.
@@ -331,6 +331,59 @@ module Bridgetown
331
331
  end
332
332
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
333
333
 
334
+ # Return an asset path based on the Webpack manifest file
335
+ # @param site [Bridgetown::Site] The current site object
336
+ # @param asset_type [String] js or css
337
+ #
338
+ # @return [String] Returns "MISSING_WEBPACK_MANIFEST" if the manifest
339
+ # file isnt found
340
+ # @return [nil] Returns nil if the asset isnt found
341
+ # @return [String] Returns the path to the asset if no issues parsing
342
+ #
343
+ # @raise [WebpackAssetError] if unable to find css or js in the manifest
344
+ # file
345
+ def parse_webpack_manifest_file(site, asset_type)
346
+ manifest_file = site.in_root_dir(".bridgetown-webpack", "manifest.json")
347
+ return "MISSING_WEBPACK_MANIFEST" unless File.exist?(manifest_file)
348
+
349
+ manifest = JSON.parse(File.read(manifest_file))
350
+
351
+ known_assets = %w(js css)
352
+ if known_assets.include?(asset_type)
353
+ asset_path = manifest["main.#{asset_type}"]
354
+
355
+ log_webpack_asset_error(asset_type) && return if asset_path.nil?
356
+
357
+ asset_path = asset_path.split("/").last
358
+ return [static_frontend_path(site), asset_type, asset_path].join("/")
359
+ end
360
+
361
+ Bridgetown.logger.error("Unknown Webpack asset type", asset_type)
362
+ nil
363
+ end
364
+
365
+ def static_frontend_path(site)
366
+ path_parts = [site.config["baseurl"].to_s.chomp("/"), "_bridgetown/static"]
367
+ path_parts[0] = "/#{path_parts[0]}" unless path_parts[0].empty?
368
+ Addressable::URI.parse(path_parts.join("/")).normalize.to_s
369
+ end
370
+
371
+ def log_webpack_asset_error(asset_type)
372
+ error_message = "There was an error parsing your #{asset_type} files. \
373
+ Please check your #{asset_type} for any errors."
374
+
375
+ Bridgetown.logger.warn(Errors::WebpackAssetError, error_message)
376
+ end
377
+
378
+ def default_github_branch_name(repo_url)
379
+ repo_match = Bridgetown::Commands::Actions::GITHUB_REPO_REGEX.match(repo_url)
380
+ api_endpoint = "https://api.github.com/repos/#{repo_match[1]}"
381
+ JSON.parse(Faraday.get(api_endpoint).body)["default_branch"] || "master"
382
+ rescue StandardError => e
383
+ Bridgetown.logger.warn("Unable to connect to GitHub API: #{e.message}")
384
+ "master"
385
+ end
386
+
334
387
  private
335
388
 
336
389
  def merge_values(target, overwrite)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.15.0.beta4"
5
- CODE_NAME = "Overlook"
4
+ VERSION = "0.17.0"
5
+ CODE_NAME = "Mount Scott"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.beta4
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-15 00:00:00.000000000 Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.4'
41
41
  - !ruby/object:Gem::Dependency
42
- name: awesome_print
42
+ name: amazing_print
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.8'
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.8'
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: colorator
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: erubi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.9'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: faraday
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +276,20 @@ dependencies:
262
276
  - - "~>"
263
277
  - !ruby/object:Gem::Version
264
278
  version: '1.0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: tilt
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '2.0'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '2.0'
265
293
  description: Bridgetown is a Webpack-aware, Ruby-powered static site generator for
266
294
  the modern Jamstack era
267
295
  email: maintainers@bridgetownrb.com
@@ -292,15 +320,21 @@ files:
292
320
  - lib/bridgetown-core/commands/registrations.rb
293
321
  - lib/bridgetown-core/commands/serve.rb
294
322
  - lib/bridgetown-core/commands/serve/servlet.rb
295
- - lib/bridgetown-core/concerns/convertible.rb
323
+ - lib/bridgetown-core/concerns/data_accessible.rb
324
+ - lib/bridgetown-core/concerns/layout_placeable.rb
325
+ - lib/bridgetown-core/concerns/liquid_renderable.rb
326
+ - lib/bridgetown-core/concerns/publishable.rb
296
327
  - lib/bridgetown-core/concerns/site/configurable.rb
297
328
  - lib/bridgetown-core/concerns/site/content.rb
298
329
  - lib/bridgetown-core/concerns/site/extensible.rb
330
+ - lib/bridgetown-core/concerns/site/localizable.rb
299
331
  - lib/bridgetown-core/concerns/site/processable.rb
300
332
  - lib/bridgetown-core/concerns/site/renderable.rb
301
333
  - lib/bridgetown-core/concerns/site/writable.rb
334
+ - lib/bridgetown-core/concerns/validatable.rb
302
335
  - lib/bridgetown-core/configuration.rb
303
336
  - lib/bridgetown-core/converter.rb
337
+ - lib/bridgetown-core/converters/erb_templates.rb
304
338
  - lib/bridgetown-core/converters/identity.rb
305
339
  - lib/bridgetown-core/converters/markdown.rb
306
340
  - lib/bridgetown-core/converters/markdown/kramdown_parser.rb
@@ -322,6 +356,7 @@ files:
322
356
  - lib/bridgetown-core/excerpt.rb
323
357
  - lib/bridgetown-core/external.rb
324
358
  - lib/bridgetown-core/filters.rb
359
+ - lib/bridgetown-core/filters/condition_helpers.rb
325
360
  - lib/bridgetown-core/filters/date_filters.rb
326
361
  - lib/bridgetown-core/filters/grouping_filters.rb
327
362
  - lib/bridgetown-core/filters/url_filters.rb
@@ -347,6 +382,7 @@ files:
347
382
  - lib/bridgetown-core/reader.rb
348
383
  - lib/bridgetown-core/readers/collection_reader.rb
349
384
  - lib/bridgetown-core/readers/data_reader.rb
385
+ - lib/bridgetown-core/readers/defaults_reader.rb
350
386
  - lib/bridgetown-core/readers/layout_reader.rb
351
387
  - lib/bridgetown-core/readers/page_reader.rb
352
388
  - lib/bridgetown-core/readers/plugin_content_reader.rb
@@ -355,13 +391,17 @@ files:
355
391
  - lib/bridgetown-core/regenerator.rb
356
392
  - lib/bridgetown-core/related_posts.rb
357
393
  - lib/bridgetown-core/renderer.rb
394
+ - lib/bridgetown-core/ruby_template_view.rb
358
395
  - lib/bridgetown-core/site.rb
359
396
  - lib/bridgetown-core/static_file.rb
397
+ - lib/bridgetown-core/tags/class_map.rb
398
+ - lib/bridgetown-core/tags/find.rb
360
399
  - lib/bridgetown-core/tags/highlight.rb
361
400
  - lib/bridgetown-core/tags/include.rb
362
401
  - lib/bridgetown-core/tags/link.rb
363
402
  - lib/bridgetown-core/tags/post_url.rb
364
403
  - lib/bridgetown-core/tags/render_content.rb
404
+ - lib/bridgetown-core/tags/t.rb
365
405
  - lib/bridgetown-core/tags/webpack_path.rb
366
406
  - lib/bridgetown-core/tags/with.rb
367
407
  - lib/bridgetown-core/url.rb
@@ -388,10 +428,10 @@ files:
388
428
  - lib/site_template/src/_components/head.liquid
389
429
  - lib/site_template/src/_components/navbar.liquid
390
430
  - lib/site_template/src/_data/site_metadata.yml
391
- - lib/site_template/src/_layouts/default.html
392
- - lib/site_template/src/_layouts/home.html
393
- - lib/site_template/src/_layouts/page.html
394
- - lib/site_template/src/_layouts/post.html
431
+ - lib/site_template/src/_layouts/default.liquid
432
+ - lib/site_template/src/_layouts/home.liquid
433
+ - lib/site_template/src/_layouts/page.liquid
434
+ - lib/site_template/src/_layouts/post.liquid
395
435
  - lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb
396
436
  - lib/site_template/src/about.md
397
437
  - lib/site_template/src/favicon.ico
@@ -1,235 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Convertible provides methods for converting a pagelike item
4
- # from a certain type of markup into actual content
5
- #
6
- # Requires
7
- # self.site -> Bridgetown::Site
8
- # self.content
9
- # self.content=
10
- # self.data=
11
- # self.ext=
12
- # self.output=
13
- # self.name
14
- # self.path
15
- # self.type -> :page or :post
16
-
17
- module Bridgetown
18
- module Convertible
19
- # Returns the contents as a String.
20
- def to_s
21
- content || ""
22
- end
23
-
24
- # Whether the file is published or not, as indicated in YAML front-matter
25
- def published?
26
- !(data.key?("published") && data["published"] == false)
27
- end
28
-
29
- # Read the YAML frontmatter.
30
- #
31
- # base - The String path to the dir containing the file.
32
- # name - The String filename of the file.
33
- # opts - optional parameter to File.read, default at site configs
34
- #
35
- # Returns nothing.
36
- # rubocop:disable Metrics/AbcSize
37
- def read_yaml(base, name, opts = {})
38
- filename = File.join(base, name)
39
-
40
- begin
41
- self.content = File.read(@path || site.in_source_dir(base, name),
42
- **Utils.merged_file_read_opts(site, opts))
43
- if content =~ Document::YAML_FRONT_MATTER_REGEXP
44
- self.content = $POSTMATCH
45
- self.data = SafeYAML.load(Regexp.last_match(1))&.with_indifferent_access
46
- end
47
- rescue Psych::SyntaxError => e
48
- Bridgetown.logger.warn "YAML Exception reading #{filename}: #{e.message}"
49
- raise e if site.config["strict_front_matter"]
50
- rescue StandardError => e
51
- Bridgetown.logger.warn "Error reading file #{filename}: #{e.message}"
52
- raise e if site.config["strict_front_matter"]
53
- end
54
-
55
- self.data ||= ActiveSupport::HashWithIndifferentAccess.new
56
-
57
- validate_data! filename
58
- validate_permalink! filename
59
-
60
- self.data
61
- end
62
- # rubocop:enable Metrics/AbcSize
63
-
64
- def validate_data!(filename)
65
- unless self.data.is_a?(Hash)
66
- raise Errors::InvalidYAMLFrontMatterError,
67
- "Invalid YAML front matter in #{filename}"
68
- end
69
- end
70
-
71
- def validate_permalink!(filename)
72
- if self.data["permalink"]&.to_s&.empty?
73
- raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}"
74
- end
75
- end
76
-
77
- # TODO: this method never seems to get called...why's it here?
78
- # Transform the contents based on the content type.
79
- #
80
- # Returns the transformed contents.
81
- def transform
82
- _renderer.convert(content)
83
- end
84
-
85
- # Determine the extension depending on content_type.
86
- #
87
- # Returns the String extension for the output file.
88
- # e.g. ".html" for an HTML output file.
89
- def output_ext
90
- _renderer.output_ext
91
- end
92
-
93
- # Determine which converter to use based on this convertible's
94
- # extension.
95
- #
96
- # Returns the Converter instance.
97
- def converters
98
- _renderer.converters
99
- end
100
-
101
- # Render Liquid in the content
102
- #
103
- # content - the raw Liquid content to render
104
- # payload - the payload for Liquid
105
- # info - the info for Liquid
106
- #
107
- # Returns the converted content
108
- def render_liquid(content, payload, info, path)
109
- _renderer.render_liquid(content, payload, info, path)
110
- end
111
-
112
- # Convert this Convertible's data to a Hash suitable for use by Liquid.
113
- #
114
- # Returns the Hash representation of this Convertible.
115
- def to_liquid(attrs = nil)
116
- further_data = \
117
- (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh|
118
- hsh[attribute] = send(attribute)
119
- end
120
-
121
- defaults = site.frontmatter_defaults.all(relative_path, type)
122
- Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
123
- end
124
-
125
- # The type of a document,
126
- # i.e., its classname downcase'd and to_sym'd.
127
- #
128
- # Returns the type of self.
129
- def type
130
- :pages if is_a?(Page)
131
- end
132
-
133
- # returns the owner symbol for hook triggering
134
- def hook_owner
135
- :pages if is_a?(Page)
136
- end
137
-
138
- # TODO: Depricated
139
- # Used to determine CoffeeScript and Sass/SCSS files.
140
- def asset_file?
141
- false
142
- end
143
-
144
- # Determine whether the file should be rendered with Liquid.
145
- #
146
- # Returns true if the file has Liquid Tags or Variables, false otherwise.
147
- def render_with_liquid?
148
- return false if data["render_with_liquid"] == false
149
-
150
- Bridgetown::Utils.has_liquid_construct?(content)
151
- end
152
-
153
- # Determine whether the file should be placed into layouts.
154
- #
155
- # Returns false if the document is an asset file or if the front matter
156
- # specifies `layout: none`
157
- def place_in_layout?
158
- !(asset_file? || no_layout?)
159
- end
160
-
161
- # Checks if the layout specified in the document actually exists
162
- #
163
- # layout - the layout to check
164
- #
165
- # Returns true if the layout is invalid, false if otherwise
166
- def invalid_layout?(layout)
167
- !data["layout"].nil? && layout.nil? && !(is_a? Bridgetown::Excerpt)
168
- end
169
-
170
- # Recursively render layouts
171
- #
172
- # layouts - a list of the layouts
173
- # payload - the payload for Liquid
174
- # info - the info for Liquid
175
- #
176
- # Returns nothing
177
- def render_all_layouts(layouts, payload, info)
178
- _renderer.layouts = layouts
179
- self.output = _renderer.place_in_layouts(output, payload, info)
180
- ensure
181
- @_renderer = nil # this will allow the modifications above to disappear
182
- end
183
-
184
- # Add any necessary layouts to this convertible document.
185
- #
186
- # payload - The site payload Drop or Hash.
187
- # layouts - A Hash of {"name" => "layout"}.
188
- #
189
- # Returns nothing.
190
- def do_layout(payload, layouts)
191
- _renderer.tap do |renderer|
192
- renderer.layouts = layouts
193
- renderer.payload = payload
194
- end.run
195
- ensure
196
- @_renderer = nil # this will allow the modifications above to disappear
197
- end
198
-
199
- # Write the generated page file to the destination directory.
200
- #
201
- # dest - The String path to the destination dir.
202
- #
203
- # Returns nothing.
204
- def write(dest)
205
- path = destination(dest)
206
- FileUtils.mkdir_p(File.dirname(path))
207
- Bridgetown.logger.debug "Writing:", path
208
- File.write(path, output, mode: "wb")
209
- Bridgetown::Hooks.trigger hook_owner, :post_write, self
210
- end
211
-
212
- # Accessor for data properties by Liquid.
213
- #
214
- # property - The String name of the property to retrieve.
215
- #
216
- # Returns the String value or nil if the property isn't included.
217
- def [](property)
218
- if self.class::ATTRIBUTES_FOR_LIQUID.include?(property)
219
- send(property)
220
- else
221
- data[property]
222
- end
223
- end
224
-
225
- private
226
-
227
- def _renderer
228
- @_renderer ||= Bridgetown::Renderer.new(site, self)
229
- end
230
-
231
- def no_layout?
232
- data["layout"] == "none"
233
- end
234
- end
235
- end