bridgetown-haml 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0957f6fb3f196bc23f9f5c410dd0edc4e83df710f40ec5b0f7e747c090452a87'
4
+ data.tar.gz: 18085ee2efc363646a5cb720516da34d8b8454981f9502068c8d62f834630062
5
+ SHA512:
6
+ metadata.gz: 1247cb315505354a88963a90373d25cc9109294d0691f4b464668ccefddefd54914b623ecefac01d22dbf6ac7d3b371bc811343f1744737d0478e07a12c72d08
7
+ data.tar.gz: 14d67d55230105b5980a65c5da51fea3e7aed88e799c3884ce5c8c00a19a46b0df6e0171d2d738cdef17e14f65b28eb4d13b41d8033c7ef01dfba17a2ddaf940
@@ -0,0 +1,38 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ .bundle
19
+ .ruby-version
20
+
21
+ # Node
22
+ node_modules
23
+ .npm
24
+ .node_repl_history
25
+
26
+ # Yarn
27
+ yarn-error.log
28
+ yarn-debug.log*
29
+ .pnp/
30
+ .pnp.js
31
+
32
+ # Yarn Integrity file
33
+ .yarn-integrity
34
+
35
+ spec/dest
36
+ .bridgetown-metadata
37
+ .bridgetown-cache
38
+ .bridgetown-webpack
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,22 @@
1
+ require: rubocop-bridgetown
2
+
3
+ inherit_gem:
4
+ rubocop-bridgetown: .rubocop.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ Include:
9
+ - lib/**/*.rb
10
+
11
+ Exclude:
12
+ - .gitignore
13
+ - .rspec
14
+ - .rubocop.yml
15
+
16
+ - Gemfile.lock
17
+ - CHANGELOG.md
18
+ - LICENSE.txt
19
+ - README.md
20
+
21
+ - script/**/*
22
+ - vendor/**/*
@@ -0,0 +1,5 @@
1
+ # main
2
+
3
+ # 1.0.0 / 2020-07-21
4
+
5
+ * First release of the bridgetown-haml plugin
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ gem "bridgetown-core", path: "../bridgetown/bridgetown-core"
7
+ gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present Jared White
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # bridgetown-haml
2
+
3
+ A Bridgetown plugin to provide support for [Haml templates](http://slim-lang.com).
4
+
5
+ _Requires Bridgetown 0.16 or greater._
6
+
7
+ ## Installation
8
+
9
+ Run this command to add this plugin to your site's Gemfile:
10
+
11
+ ```shell
12
+ $ bundle add bridgetown-haml -g bridgetown_plugins
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Simply name your page, layout, or partial with a `.haml` extension. The available features will be fairly analogous to [the ERB support](https://beta.bridgetownrb.com/docs/erb-and-beyond#haml-and-slim) in Bridgetown, including support for helpers, partials, and rendering Liquid components. You can even [embed Markdown and other template languages](https://github.com/haml/haml/blob/master/REFERENCE.md#filters-filters) using standard Haml syntax.
18
+
19
+ ## Testing
20
+
21
+ * Run `bundle exec rspec` to run the test suite
22
+ * Or run `script/cibuild` to validate with Rubocop and test with rspec together.
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it (https://github.com/bridgetown/bridgetown-haml/fork)
27
+ 2. Clone the fork using `git clone` to your local development machine.
28
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 5. Push to the branch (`git push origin my-new-feature`)
31
+ 6. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bridgetown-haml/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bridgetown-haml"
7
+ spec.version = BridgetownHaml::VERSION
8
+ spec.author = "Bridgetown Team"
9
+ spec.email = "maintainers@bridgetownrb.com"
10
+ spec.summary = "A Bridgetown plugin which provides support for Haml templates."
11
+ spec.homepage = "https://github.com/bridgetown/bridgetown-haml"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
15
+ spec.test_files = spec.files.grep(%r!^spec/!)
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.required_ruby_version = ">= 2.5.0"
19
+
20
+ spec.add_dependency "bridgetown", ">= 0.16.0.beta1", "< 2.0"
21
+ spec.add_dependency "haml", ">= 5.1.2"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "nokogiri", "~> 1.6"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
28
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridgetown"
4
+ require "bridgetown-haml/haml_templates"
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tilt/haml"
4
+
5
+ module Bridgetown
6
+ class HamlView < RubyTemplateView
7
+ def partial(partial_name, options = {})
8
+ options.merge!(options[:locals]) if options[:locals]
9
+
10
+ partial_segments = partial_name.split("/")
11
+ partial_segments.last.sub!(%r!^!, "_")
12
+ partial_name = partial_segments.join("/")
13
+
14
+ Tilt::HamlTemplate.new(
15
+ site.in_source_dir(site.config[:partials_dir], "#{partial_name}.haml")
16
+ ).render(self, options)
17
+ end
18
+ end
19
+
20
+ module Converters
21
+ class HamlTemplates < Converter
22
+ input :haml
23
+
24
+ # Logic to do the Haml content conversion.
25
+ #
26
+ # @param content [String] Content of the file (without front matter).
27
+ # @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
28
+ # The instantiated object which is processing the file.
29
+ #
30
+ # @return [String] The converted content.
31
+ def convert(content, convertible)
32
+ haml_view = Bridgetown::HamlView.new(convertible)
33
+
34
+ haml_renderer = Tilt::HamlTemplate.new(convertible.relative_path) { content }
35
+
36
+ if convertible.is_a?(Bridgetown::Layout)
37
+ haml_renderer.render(haml_view) do
38
+ convertible.current_document_output
39
+ end
40
+ else
41
+ haml_renderer.render(haml_view)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgetownHaml
4
+ VERSION = "1.0.0"
5
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bridgetown-haml
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bridgetown Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bridgetown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.16.0.beta1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.16.0.beta1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: haml
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 5.1.2
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.1.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: nokogiri
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.6'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.6'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '12.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '12.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-bridgetown
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.2'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.2'
117
+ description:
118
+ email: maintainers@bridgetownrb.com
119
+ executables: []
120
+ extensions: []
121
+ extra_rdoc_files: []
122
+ files:
123
+ - ".gitignore"
124
+ - ".rspec"
125
+ - ".rubocop.yml"
126
+ - CHANGELOG.md
127
+ - Gemfile
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bridgetown-haml.gemspec
132
+ - lib/bridgetown-haml.rb
133
+ - lib/bridgetown-haml/haml_templates.rb
134
+ - lib/bridgetown-haml/version.rb
135
+ homepage: https://github.com/bridgetown/bridgetown-haml
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.5.0
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.0.6
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: A Bridgetown plugin which provides support for Haml templates.
158
+ test_files: []