bridgetown-core 0.19.1 → 0.21.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +3 -4
- data/lib/bridgetown-core.rb +32 -16
- data/lib/bridgetown-core/cleaner.rb +7 -1
- data/lib/bridgetown-core/collection.rb +176 -77
- data/lib/bridgetown-core/commands/apply.rb +4 -3
- data/lib/bridgetown-core/commands/base.rb +9 -0
- data/lib/bridgetown-core/commands/build.rb +0 -11
- data/lib/bridgetown-core/commands/configure.rb +66 -0
- data/lib/bridgetown-core/commands/console.rb +4 -0
- data/lib/bridgetown-core/commands/doctor.rb +1 -19
- data/lib/bridgetown-core/commands/new.rb +8 -0
- data/lib/bridgetown-core/commands/plugins.rb +1 -0
- data/lib/bridgetown-core/commands/serve.rb +0 -14
- data/lib/bridgetown-core/component.rb +178 -0
- data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
- data/lib/bridgetown-core/concerns/site/configurable.rb +7 -3
- data/lib/bridgetown-core/concerns/site/content.rb +56 -15
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +12 -2
- data/lib/bridgetown-core/concerns/validatable.rb +1 -4
- data/lib/bridgetown-core/configuration.rb +50 -29
- data/lib/bridgetown-core/configurations/.keep +0 -0
- data/lib/bridgetown-core/configurations/bt-postcss.rb +26 -0
- data/lib/bridgetown-core/configurations/bt-postcss/postcss.config.js +21 -0
- data/lib/bridgetown-core/configurations/minitesting.rb +95 -0
- data/lib/bridgetown-core/configurations/netlify.rb +6 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.sh +14 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.toml +44 -0
- data/lib/bridgetown-core/configurations/purgecss.rb +49 -0
- data/lib/bridgetown-core/configurations/stimulus.rb +49 -0
- data/lib/bridgetown-core/configurations/swup.rb +37 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +29 -0
- data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +4 -0
- data/lib/bridgetown-core/configurations/tailwindcss/postcss.config.js +12 -0
- data/lib/bridgetown-core/configurations/turbo.rb +16 -0
- data/lib/bridgetown-core/converter.rb +23 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +50 -41
- data/lib/bridgetown-core/converters/identity.rb +0 -9
- data/lib/bridgetown-core/converters/markdown.rb +14 -4
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +5 -38
- data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
- data/lib/bridgetown-core/converters/smartypants.rb +3 -1
- data/lib/bridgetown-core/current.rb +10 -0
- data/lib/bridgetown-core/document.rb +7 -14
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/page_drop.rb +4 -0
- data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
- data/lib/bridgetown-core/drops/resource_drop.rb +83 -0
- data/lib/bridgetown-core/drops/site_drop.rb +33 -8
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +5 -0
- data/lib/bridgetown-core/entry_filter.rb +12 -25
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/filters.rb +4 -27
- data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
- data/lib/bridgetown-core/filters/url_filters.rb +12 -0
- data/lib/bridgetown-core/generator.rb +2 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +37 -19
- data/lib/bridgetown-core/helpers.rb +48 -9
- data/lib/bridgetown-core/layout.rb +28 -13
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
- data/lib/bridgetown-core/model/base.rb +138 -0
- data/lib/bridgetown-core/model/builder_origin.rb +40 -0
- data/lib/bridgetown-core/model/origin.rb +38 -0
- data/lib/bridgetown-core/model/repo_origin.rb +126 -0
- data/lib/bridgetown-core/page.rb +11 -2
- data/lib/bridgetown-core/plugin.rb +2 -26
- data/lib/bridgetown-core/plugin_manager.rb +1 -3
- data/lib/bridgetown-core/publisher.rb +7 -1
- data/lib/bridgetown-core/reader.rb +36 -21
- data/lib/bridgetown-core/readers/data_reader.rb +4 -4
- data/lib/bridgetown-core/readers/page_reader.rb +1 -0
- data/lib/bridgetown-core/readers/post_reader.rb +5 -4
- data/lib/bridgetown-core/regenerator.rb +8 -1
- data/lib/bridgetown-core/related_posts.rb +5 -5
- data/lib/bridgetown-core/renderer.rb +6 -13
- data/lib/bridgetown-core/resource/base.rb +317 -0
- data/lib/bridgetown-core/resource/destination.rb +49 -0
- data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
- data/lib/bridgetown-core/resource/relations.rb +132 -0
- data/lib/bridgetown-core/resource/taxonomy_term.rb +34 -0
- data/lib/bridgetown-core/resource/taxonomy_type.rb +56 -0
- data/lib/bridgetown-core/resource/transformer.rb +175 -0
- data/lib/bridgetown-core/ruby_template_view.rb +12 -4
- data/lib/bridgetown-core/site.rb +9 -1
- data/lib/bridgetown-core/static_file.rb +33 -10
- data/lib/bridgetown-core/tags/include.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +2 -2
- data/lib/bridgetown-core/url.rb +1 -0
- data/lib/bridgetown-core/utils.rb +49 -43
- data/lib/bridgetown-core/utils/require_gems.rb +60 -0
- data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +1 -1
- data/lib/site_template/README.md +70 -0
- data/lib/site_template/package.json.erb +2 -2
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
- data/lib/site_template/webpack.config.js.erb +26 -6
- metadata +56 -44
- data/lib/bridgetown-core/external.rb +0 -58
- data/lib/bridgetown-core/page_without_a_file.rb +0 -17
- data/lib/bridgetown-core/path_manager.rb +0 -31
- data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
- data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
- data/lib/bridgetown-core/utils/exec.rb +0 -26
- data/lib/bridgetown-core/utils/internet.rb +0 -37
- data/lib/bridgetown-core/utils/platforms.rb +0 -80
- data/lib/bridgetown-core/utils/thread_event.rb +0 -31
- data/lib/bridgetown-core/utils/win_tz.rb +0 -75
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Resource
|
5
|
+
class Relations
|
6
|
+
# @return [Bridgetown::Resource::Base]
|
7
|
+
attr_reader :resource
|
8
|
+
|
9
|
+
# @return [Bridgetown::Site]
|
10
|
+
attr_reader :site
|
11
|
+
|
12
|
+
# @param resource [Bridgetown::Resource::Base]
|
13
|
+
def initialize(resource)
|
14
|
+
@resource = resource
|
15
|
+
@site = resource.site
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [HashWithDotAccess::Hash]
|
19
|
+
def relation_schema
|
20
|
+
resource.collection.metadata.relations
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Array<String>]
|
24
|
+
def relation_types
|
25
|
+
@relation_types ||= begin
|
26
|
+
types = []
|
27
|
+
relation_schema&.each do |_relation_type, collections|
|
28
|
+
types << collections
|
29
|
+
types << Array(collections).map { |item| ActiveSupport::Inflector.pluralize(item) }
|
30
|
+
end
|
31
|
+
types.flatten.uniq
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param type [Symbol]
|
36
|
+
# @return [Bridgetown::Resource::Base, Array<Bridgetown::Resource::Base>]
|
37
|
+
def resources_for_type(type)
|
38
|
+
relation_kind = kind_of_relation_for_type(type)
|
39
|
+
return [] unless relation_kind
|
40
|
+
|
41
|
+
case relation_kind.to_sym
|
42
|
+
when :belongs_to
|
43
|
+
belongs_to_relation_for_type(type)
|
44
|
+
when :has_many
|
45
|
+
has_many_relation_for_type(type)
|
46
|
+
when :has_one
|
47
|
+
has_one_relation_for_type(type)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing(type, *args)
|
52
|
+
return super unless type.to_s.in?(relation_types)
|
53
|
+
|
54
|
+
resources_for_type(type)
|
55
|
+
end
|
56
|
+
|
57
|
+
def respond_to_missing?(type, *_args)
|
58
|
+
type.to_s.in?(relation_types)
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_liquid
|
62
|
+
@to_liquid ||= Drops::RelationsDrop.new(self)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# @param type [Symbol]
|
68
|
+
# @return [String]
|
69
|
+
def kind_of_relation_for_type(type)
|
70
|
+
relation_schema&.each do |relation_type, collections|
|
71
|
+
collections = Array(collections).yield_self do |collections_arr|
|
72
|
+
collections_arr +
|
73
|
+
collections_arr.map { |item| ActiveSupport::Inflector.pluralize(item) }
|
74
|
+
end.flatten.uniq
|
75
|
+
return relation_type if collections.include?(type.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# @param type [Symbol]
|
80
|
+
# @return [Bridgetown::Collection]
|
81
|
+
def other_collection_for_type(type)
|
82
|
+
site.collections[type] || site.collections[ActiveSupport::Inflector.pluralize(type)]
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Array<String>]
|
86
|
+
def collection_labels
|
87
|
+
[
|
88
|
+
resource.collection.label,
|
89
|
+
ActiveSupport::Inflector.singularize(resource.collection.label),
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
# @param type [Symbol]
|
94
|
+
# @return [Bridgetown::Resource::Base, Array<Bridgetown::Resource::Base>]
|
95
|
+
def belongs_to_relation_for_type(type)
|
96
|
+
if resource.data[type].is_a?(Array)
|
97
|
+
other_collection_for_type(type).resources.select do |other_resource|
|
98
|
+
other_resource.data.slug.in?(resource.data[type])
|
99
|
+
end
|
100
|
+
else
|
101
|
+
other_collection_for_type(type).resources.find do |other_resource|
|
102
|
+
other_resource.data.slug == resource.data[type]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# @param type [Symbol]
|
108
|
+
# @return [Array<Bridgetown::Resource::Base>]
|
109
|
+
def has_many_relation_for_type(type) # rubocop:disable Naming/PredicateName
|
110
|
+
label, singular_label = collection_labels
|
111
|
+
|
112
|
+
other_collection_for_type(type).resources.select do |other_resource|
|
113
|
+
resource.data.slug.in?(
|
114
|
+
Array(other_resource.data[label] || other_resource.data[singular_label])
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# @param type [Symbol]
|
120
|
+
# @return [Bridgetown::Resource::Base]
|
121
|
+
def has_one_relation_for_type(type) # rubocop:disable Naming/PredicateName
|
122
|
+
label, singular_label = collection_labels
|
123
|
+
|
124
|
+
other_collection_for_type(type).resources.find do |other_resource|
|
125
|
+
resource.data.slug.in?(
|
126
|
+
Array(other_resource.data[label] || other_resource.data[singular_label])
|
127
|
+
)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Resource
|
5
|
+
class TaxonomyTerm
|
6
|
+
attr_reader :resource
|
7
|
+
|
8
|
+
attr_reader :label
|
9
|
+
|
10
|
+
attr_reader :type
|
11
|
+
|
12
|
+
def initialize(resource:, label:, type:)
|
13
|
+
@resource = resource
|
14
|
+
@label = label
|
15
|
+
@type = type
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_liquid
|
19
|
+
{
|
20
|
+
"label" => label,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
alias_method :to_h, :to_liquid
|
24
|
+
|
25
|
+
def as_json(*)
|
26
|
+
to_h
|
27
|
+
end
|
28
|
+
|
29
|
+
ruby2_keywords def to_json(*options)
|
30
|
+
as_json(*options).to_json(*options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Resource
|
5
|
+
class TaxonomyType
|
6
|
+
# @return [Bridgetown::Site]
|
7
|
+
attr_reader :site
|
8
|
+
|
9
|
+
# @return [String] aka `category`, `tag`, `region`, etc.
|
10
|
+
attr_reader :label
|
11
|
+
|
12
|
+
# @return [String] the key used in front matter
|
13
|
+
attr_reader :key
|
14
|
+
|
15
|
+
# @return [HashWithDotAccess::Hash] any associated metadata
|
16
|
+
attr_reader :metadata
|
17
|
+
|
18
|
+
# @param site [Bridgetown::Site]
|
19
|
+
# @param label [String]
|
20
|
+
# @param key [String]
|
21
|
+
def initialize(site:, label:, key:, metadata:)
|
22
|
+
@site = site
|
23
|
+
@label = label
|
24
|
+
@key = key
|
25
|
+
@metadata = metadata
|
26
|
+
end
|
27
|
+
|
28
|
+
def terms
|
29
|
+
site.resources.map do |resource|
|
30
|
+
resource.taxonomies[label].terms
|
31
|
+
end.flatten.group_by(&:label).with_dot_access
|
32
|
+
end
|
33
|
+
|
34
|
+
def inspect
|
35
|
+
"#<#{self.class} label=#{label}>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_liquid
|
39
|
+
{
|
40
|
+
"label" => label,
|
41
|
+
"key" => key,
|
42
|
+
"metadata" => metadata,
|
43
|
+
}
|
44
|
+
end
|
45
|
+
alias_method :to_h, :to_liquid
|
46
|
+
|
47
|
+
def as_json(*)
|
48
|
+
to_h
|
49
|
+
end
|
50
|
+
|
51
|
+
ruby2_keywords def to_json(*options)
|
52
|
+
as_json(*options).to_json(*options)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Resource
|
5
|
+
class Transformer
|
6
|
+
# @return [Array<Hash>]
|
7
|
+
attr_reader :conversions
|
8
|
+
|
9
|
+
# @return [Bridgetown::Resource::Base]
|
10
|
+
attr_reader :resource
|
11
|
+
|
12
|
+
# @return [Bridgetown::Site]
|
13
|
+
attr_reader :site
|
14
|
+
|
15
|
+
def initialize(resource)
|
16
|
+
@resource = resource
|
17
|
+
@site = resource.site
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def output_ext
|
22
|
+
@output_ext ||= output_ext_from_converters
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def final_ext
|
27
|
+
output_ext # we always need this to get run
|
28
|
+
|
29
|
+
permalink_ext || output_ext
|
30
|
+
end
|
31
|
+
|
32
|
+
def process!
|
33
|
+
Bridgetown.logger.debug "Transforming:", resource.relative_path
|
34
|
+
resource.around_hook :render do
|
35
|
+
run_conversions
|
36
|
+
resource.place_in_layout? ? place_into_layouts : resource.output = resource.content.dup
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute_inline_ruby!
|
41
|
+
return unless site.config.should_execute_inline_ruby?
|
42
|
+
|
43
|
+
Bridgetown::Utils::RubyExec.search_data_for_ruby_code(resource, self)
|
44
|
+
end
|
45
|
+
|
46
|
+
def inspect
|
47
|
+
"#<#{self.class} Conversion Steps: #{conversions.length}>"
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
### Utilities
|
53
|
+
|
54
|
+
def permalink_ext
|
55
|
+
resource_permalink = resource.permalink
|
56
|
+
if resource_permalink &&
|
57
|
+
!resource_permalink.end_with?("/") &&
|
58
|
+
!resource_permalink.end_with?(".*")
|
59
|
+
permalink_ext = File.extname(resource_permalink)
|
60
|
+
permalink_ext unless permalink_ext.empty?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Array<Bridgetown::Converter>]
|
65
|
+
def converters
|
66
|
+
@converters ||= site.matched_converters_for_convertible(resource)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [String]
|
70
|
+
def output_ext_from_converters
|
71
|
+
@conversions = converters.map do |converter|
|
72
|
+
{
|
73
|
+
converter: converter,
|
74
|
+
output_ext: converter.output_ext(resource.extname),
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
conversions
|
79
|
+
.reverse
|
80
|
+
.find do |conversion|
|
81
|
+
conversions.length == 1 ||
|
82
|
+
!conversion[:converter].is_a?(Bridgetown::Converters::Identity)
|
83
|
+
end
|
84
|
+
.fetch(:output_ext)
|
85
|
+
end
|
86
|
+
|
87
|
+
# @return [Array<Bridgetown::Layout>]
|
88
|
+
def validated_layouts
|
89
|
+
layout = site.layouts[resource.data.layout]
|
90
|
+
warn_on_missing_layout layout, resource.data.layout
|
91
|
+
|
92
|
+
layout_list = Set.new([layout])
|
93
|
+
while layout
|
94
|
+
layout_name = layout.data.layout
|
95
|
+
layout = site.layouts[layout_name]
|
96
|
+
warn_on_missing_layout layout, layout_name
|
97
|
+
|
98
|
+
layout_list << layout
|
99
|
+
end
|
100
|
+
|
101
|
+
layout_list.to_a.compact
|
102
|
+
end
|
103
|
+
|
104
|
+
def warn_on_missing_layout(layout, layout_name)
|
105
|
+
if layout.nil? && layout_name
|
106
|
+
Bridgetown.logger.warn "Build Warning:", "Layout '#{layout_name}' " \
|
107
|
+
"requested via #{resource.relative_path} does not exist."
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
### Transformation Actions
|
112
|
+
|
113
|
+
def run_conversions # rubocop:disable Metrics/AbcSize
|
114
|
+
input = resource.content.to_s
|
115
|
+
|
116
|
+
# @param content [String]
|
117
|
+
# @param converter [Bridgetown::Converter]
|
118
|
+
resource.content = converters.each_with_index.inject(input) do |content, (converter, index)|
|
119
|
+
output = if converter.method(:convert).arity == 1
|
120
|
+
converter.convert content
|
121
|
+
else
|
122
|
+
converter.convert content, resource
|
123
|
+
end
|
124
|
+
conversions[index] = {
|
125
|
+
type: :content,
|
126
|
+
converter: converter,
|
127
|
+
output: Bridgetown.env.production? ? nil : output,
|
128
|
+
output_ext: conversions[index][:output_ext],
|
129
|
+
}
|
130
|
+
output.html_safe
|
131
|
+
rescue StandardError => e
|
132
|
+
Bridgetown.logger.error "Conversion error:",
|
133
|
+
"#{converter.class} encountered an error while "\
|
134
|
+
"converting `#{resource.relative_path}'"
|
135
|
+
raise e
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def place_into_layouts
|
140
|
+
Bridgetown.logger.debug "Placing in Layouts:", resource.relative_path
|
141
|
+
output = resource.content.dup
|
142
|
+
validated_layouts.each do |layout|
|
143
|
+
output = run_layout_conversions layout, output
|
144
|
+
end
|
145
|
+
resource.output = output
|
146
|
+
end
|
147
|
+
|
148
|
+
def run_layout_conversions(layout, output)
|
149
|
+
layout_converters = site.matched_converters_for_convertible(layout)
|
150
|
+
layout_input = layout.content.dup
|
151
|
+
|
152
|
+
layout_converters.inject(layout_input) do |content, converter|
|
153
|
+
next(content) unless [2, -2].include?(converter.method(:convert).arity)
|
154
|
+
|
155
|
+
layout.current_document = resource
|
156
|
+
layout.current_document_output = output
|
157
|
+
layout_output = converter.convert content, layout
|
158
|
+
|
159
|
+
conversions << {
|
160
|
+
type: :layout,
|
161
|
+
layout: layout,
|
162
|
+
converter: converter,
|
163
|
+
output: Bridgetown.env.production? ? nil : layout_output,
|
164
|
+
}
|
165
|
+
layout_output
|
166
|
+
rescue StandardError => e
|
167
|
+
Bridgetown.logger.error "Conversion error:",
|
168
|
+
"#{converter.class} encountered an error while "\
|
169
|
+
"converting `#{resource.relative_path}'"
|
170
|
+
raise e
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -7,6 +7,7 @@ module Bridgetown
|
|
7
7
|
require "bridgetown-core/helpers"
|
8
8
|
|
9
9
|
attr_reader :layout, :page, :paginator, :site, :content
|
10
|
+
alias_method :resource, :page
|
10
11
|
|
11
12
|
def initialize(convertible)
|
12
13
|
if convertible.is_a?(Layout)
|
@@ -27,12 +28,17 @@ module Bridgetown
|
|
27
28
|
|
28
29
|
def render(item, options = {}, &block)
|
29
30
|
if item.respond_to?(:render_in)
|
30
|
-
item.render_in(self, &block)
|
31
|
+
result = item.render_in(self, &block)
|
32
|
+
result&.html_safe
|
31
33
|
else
|
32
|
-
partial(item, options, &block)
|
34
|
+
partial(item, options, &block)&.html_safe
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
def collections
|
39
|
+
site.collections
|
40
|
+
end
|
41
|
+
|
36
42
|
def site_drop
|
37
43
|
site.site_payload.site
|
38
44
|
end
|
@@ -48,14 +54,15 @@ module Bridgetown
|
|
48
54
|
Bridgetown.logger.warn "Liquid Warning:",
|
49
55
|
LiquidRenderer.format_error(e, path || document.relative_path)
|
50
56
|
end
|
51
|
-
template.render!(options.deep_stringify_keys, _liquid_context)
|
57
|
+
template.render!(options.deep_stringify_keys, _liquid_context).html_safe
|
52
58
|
end
|
53
59
|
|
54
60
|
def helpers
|
55
61
|
@helpers ||= Helpers.new(self, site)
|
56
62
|
end
|
57
63
|
|
58
|
-
|
64
|
+
# rubocop:disable Style/MissingRespondToMissing
|
65
|
+
ruby2_keywords def method_missing(method, *args, &block)
|
59
66
|
if helpers.respond_to?(method.to_sym)
|
60
67
|
helpers.send method.to_sym, *args, &block
|
61
68
|
else
|
@@ -66,6 +73,7 @@ module Bridgetown
|
|
66
73
|
def respond_to_missing?(method, include_private = false)
|
67
74
|
helpers.respond_to?(method.to_sym, include_private) || super
|
68
75
|
end
|
76
|
+
# rubocop:enable Style/MissingRespondToMissing
|
69
77
|
|
70
78
|
private
|
71
79
|
|