vident-better_html 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a40746542811fa91482ca11c7f5acd97ceca9d8f26cff6800174c01e7e7b7d63
4
+ data.tar.gz: 006b1b367ff816117bcd74b5c521d13d47e997112d30849f8774ab2dcf5c1788
5
+ SHA512:
6
+ metadata.gz: a8a6c01f12d967caecc7ea2d3782cd05d84aa3fa34be9d833382a374181397c1d2c89edded86c02574002be775359115d7f38713ced0910248a4c4f7a85a414a
7
+ data.tar.gz: a338462bef2e2af41558ae896fcdfa1f50ee3bf743fe59fe90439515be9a538c4f5e55572ac3a8b2ba1d45f989a75630561c712b90e16ba07642b4ddcdcd7f84
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Vident::BetterHtml
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ```ruby
8
+ BetterHtml.config = BetterHtml::Config.new(YAML.load(File.read(".better-html.yml")))
9
+
10
+ BetterHtml.configure do |config|
11
+ config.template_exclusion_filter = proc { |filename| !filename.start_with?(Rails.root.to_s) }
12
+ end
13
+ # ViewComponent needs to do this hack to work in certain cases
14
+ # see https://github.com/Shopify/better-html/pull/98
15
+ class BetterHtml::HtmlAttributes
16
+ alias_method :to_s_without_html_safe, :to_s
17
+
18
+ def to_s
19
+ to_s_without_html_safe.html_safe
20
+ end
21
+ end
22
+ ```
23
+
24
+ ## Installation
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```ruby
28
+ gem "vident-better_html"
29
+ ```
30
+
31
+ And then execute:
32
+ ```bash
33
+ $ bundle
34
+ ```
35
+
36
+ Or install it yourself as:
37
+ ```bash
38
+ $ gem install vident-better_html
39
+ ```
40
+
41
+ ## Contributing
42
+ Contribution directions go here.
43
+
44
+ ## License
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :vident_better_html do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,6 @@
1
+ module Vident
2
+ module BetterHtml
3
+ class Railtie < ::Rails::Railtie
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ require "vident/better_html/version"
2
+ require "vident/better_html/railtie"
3
+
4
+ require "cgi/util"
5
+
6
+ module Vident
7
+ module BetterHtml
8
+ module RootComponent
9
+ # Return the HTML `data-controller` attribute for the given controllers
10
+ def with_controllers(*controllers_to_set)
11
+ helpers.html_attributes("data-controller" => controller_list(controllers_to_set)&.html_safe)
12
+ end
13
+
14
+ # Return the HTML `data-target` attribute for the given targets
15
+ def as_targets(*targets)
16
+ attrs = build_target_data_attributes(parse_targets(targets))
17
+ helpers.html_attributes(attrs.transform_keys! { |k| "data-#{k}" })
18
+ end
19
+ alias_method :as_target, :as_targets
20
+
21
+ # Return the HTML `data-action` attribute for the given actions
22
+ def with_actions(*actions_to_set)
23
+ actions_str = action_list(actions_to_set)
24
+ actions_str.present? ? helpers.html_attributes("data-action" => actions_str) : nil
25
+ end
26
+ alias_method :with_action, :with_actions
27
+
28
+ private
29
+
30
+ # Complete list of actions ready to be use in the data-action attribute
31
+ def action_list(actions_to_parse)
32
+ return nil unless actions_to_parse&.size&.positive?
33
+ # `html_attributes` will escape '->' thus breaking the stimulus action, so we need to do our own escaping
34
+ actions_str_raw = parse_actions(actions_to_parse).join(" ")
35
+ CGI.escapeHTML(actions_str_raw).gsub("-&gt;", "->").html_safe
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ module Vident
2
+ module BetterHtml
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "vident/better_html/version"
2
+ require "vident/better_html/railtie"
3
+ require "vident/better_html/root_component"
4
+
5
+ module Vident
6
+ module BetterHtml
7
+ # Your code goes here...
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vident-better_html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Ierodiaconou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '7'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: vident
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.8.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '1'
53
+ - !ruby/object:Gem::Dependency
54
+ name: better_html
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '3'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '3'
73
+ description: Vident support for better_html. If you use better_html, you will need
74
+ to install this gem too.
75
+ email:
76
+ - stevegeek@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - README.md
82
+ - Rakefile
83
+ - lib/tasks/vident/better_html_tasks.rake
84
+ - lib/vident/better_html.rb
85
+ - lib/vident/better_html/railtie.rb
86
+ - lib/vident/better_html/root_component.rb
87
+ - lib/vident/better_html/version.rb
88
+ homepage: https://github.com/stevegeek/vident-better_html
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ homepage_uri: https://github.com/stevegeek/vident-better_html
93
+ source_code_uri: https://github.com/stevegeek/vident-better_html
94
+ changelog_uri: https://github.com/stevegeek/vident-better_html/blob/main/CHANGELOG.md
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.4.6
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Vident support for BetterHTML.
114
+ test_files: []