phlex 1.10.1 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf84b97b1bea4f96f14b9cb01c649c12bc838fcf2e2f8c305e7d6b5ea26bb78e
4
- data.tar.gz: 1a310b4f74440e8131ebc8ae7847f1c9fb6b371d3015c67f2da373ebf75ee038
3
+ metadata.gz: 4a86bca32b72f150179b586843c71432ebfea0d892ad70b426ef0f8ce6d58f3f
4
+ data.tar.gz: 235a24dc555ffcb1598660c9c5d539a5b050780a1ccec4d81b8b5115ea5b7f0e
5
5
  SHA512:
6
- metadata.gz: 5e245d5943e46753a1ce044e620252e03353e5ffec1da5a21a158ad7c4ff2080b2fc47388b6af7da73db94a434ece93bb1c119a6498fc11291127e6e0b51aa85
7
- data.tar.gz: 8772d302dbbe246b7200886403c3f2dbb7129b54f729b7cac4e13809cbdf5b9896aa6cabc23ae7b1b09df41c79ef8ec0b74be925f8cd2ca75fe726cdd7fc9011
6
+ metadata.gz: 0b4ab7f24ba4955cc0622da21a363436a0b54cae4505ec0fd599dd2ddd53731175386b5fc9f62981807f7836d34edd7de851dd662a18b1e01c3935aa37956454
7
+ data.tar.gz: eb0b42b41d70b8fb28ae3c9134f0ecddcc517698ac812c2f1c69b05c4b41d7d9148aca244d88b1bb8e8d817abcfafa9ac6968342890584b9b6cf539b320e2b27
data/lib/phlex/sgml.rb CHANGED
@@ -216,10 +216,14 @@ module Phlex
216
216
  # Capture a block of output as a String.
217
217
  # @note This only works if the block's receiver is the current component or the block returns a String.
218
218
  # @return [String]
219
- def capture(&block)
219
+ def capture(*args, &block)
220
220
  return "" unless block
221
221
 
222
- @_context.capturing_into(+"") { yield_content(&block) }
222
+ if args.length > 0
223
+ @_context.capturing_into(+"") { yield_content_with_args(*args, &block) }
224
+ else
225
+ @_context.capturing_into(+"") { yield_content(&block) }
226
+ end
223
227
  end
224
228
 
225
229
  private
@@ -424,10 +428,10 @@ module Phlex
424
428
  end
425
429
 
426
430
  lower_name = name.downcase
427
- next if lower_name == "href" && v.to_s.downcase.tr("\t \n", "").start_with?("javascript:")
431
+ next if lower_name == "href" && v.to_s.downcase.tr("^a-z:", "").start_with?("javascript:")
428
432
 
429
433
  # Detect unsafe attribute names. Attribute names are considered unsafe if they match an event attribute or include unsafe characters.
430
- if HTML::EVENT_ATTRIBUTES[lower_name] || name.match?(/[<>&"']/)
434
+ if HTML::EVENT_ATTRIBUTES.include?(lower_name.tr("^a-z-", "")) || name.match?(/[<>&"']/)
431
435
  raise ArgumentError, "Unsafe attribute name detected: #{k}."
432
436
  end
433
437
 
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "1.10.1"
4
+ VERSION = "1.10.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
11
+ date: 2024-06-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A high-performance view framework optimised for fun.
14
14
  email:
@@ -17,28 +17,8 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".editorconfig"
21
- - ".rubocop.yml"
22
- - ".ruby-version"
23
- - ".solargraph.yml"
24
- - ".yardopts"
25
- - CHANGELOG.md
26
- - CODE_OF_CONDUCT.md
27
- - CONTRIBUTING.md
28
- - Gemfile
29
20
  - LICENSE.txt
30
21
  - README.md
31
- - SECURITY.md
32
- - bench.rb
33
- - config/sus.rb
34
- - fixtures/components.rb
35
- - fixtures/components/say_hi.rb
36
- - fixtures/layout.rb
37
- - fixtures/page.rb
38
- - fixtures/view_helper.rb
39
- - gd/phlex/callable.rb
40
- - gd/phlex/sgml/attributes.rb
41
- - gd/support/helper.rb
42
22
  - lib/phlex.rb
43
23
  - lib/phlex/black_hole.rb
44
24
  - lib/phlex/callable.rb
@@ -58,8 +38,6 @@ files:
58
38
  - lib/phlex/testing/view_helper.rb
59
39
  - lib/phlex/unbuffered.rb
60
40
  - lib/phlex/version.rb
61
- - phlex_logo.png
62
- - sig/phlex.rbs
63
41
  homepage: https://www.phlex.fun
64
42
  licenses:
65
43
  - MIT
@@ -84,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
62
  - !ruby/object:Gem::Version
85
63
  version: '0'
86
64
  requirements: []
87
- rubygems_version: 3.5.9
65
+ rubygems_version: 3.5.3
88
66
  signing_key:
89
67
  specification_version: 4
90
68
  summary: A fun framework for building views in Ruby.
data/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
7
- [*.yml]
8
- indent_style = space
9
- indent_size = 2
10
-
11
- [*.erb]
12
- indent_style = space
13
- indent_size = 2
data/.rubocop.yml DELETED
@@ -1,27 +0,0 @@
1
- inherit_from:
2
- - "https://www.goodcop.style/rubocop.yml"
3
- - "https://www.goodcop.style/tabs.yml"
4
-
5
- AllCops:
6
- TargetRubyVersion: 2.7
7
-
8
- Style/ExplicitBlockArgument:
9
- Enabled: false
10
-
11
- Style/MixinUsage:
12
- Enabled: false
13
-
14
- Style/RedundantDoubleSplatHashBraces:
15
- Enabled: false
16
-
17
- Style/OptionalArguments:
18
- Enabled: false
19
-
20
- Naming/AsciiIdentifiers:
21
- Enabled: false
22
-
23
- Naming/MethodName:
24
- Enabled: false
25
-
26
- Style/ReturnNilInPredicateMethodDefinition:
27
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.0
data/.solargraph.yml DELETED
@@ -1,11 +0,0 @@
1
- include:
2
- - "**/*.rb"
3
- exclude:
4
- - test/**/*
5
- require: []
6
- domains: []
7
- reporters:
8
- - rubocop
9
- - require_not_found
10
- - typecheck
11
- max_files: 0
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --private --hide-api private --markup markdown
data/CHANGELOG.md DELETED
@@ -1,62 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
-
5
- ## [1.10.0] 2024-04-05
6
-
7
- - [Added] new `Phlex::CSV` class for streaming CSV views
8
- - [Added] new (experimental) `Phlex::Kit` for collections of components
9
- - [Added] support for selective rendering
10
- - [Changed] `mix` does a better job when mixing different types of attributes
11
- - [Changed] Phlex will now try to call `to_s` on attribute values
12
- - [Changed] No runtime dependencies
13
- - [Deprecated] `Phlex::HTML#param`, (`<param>`) tags have been deprecated
14
- - [Deprecated] Defining the `template` method is now deprecated. You should define `view_template` instead. In Phlex 2.0, the `template` method will render a `<template>` tag.
15
-
16
- # [1.9.1] 2024-03-11
17
-
18
- - Security update
19
-
20
- ## [1.9.0] 2024-11-24
21
-
22
- - Improved documentation
23
- - Fixed an issue with flushing to the buffer while capturing
24
- - Added `<canvas>` element
25
- - Very minor performance improvements by using `block` instead of `block_given?` where a block has already been captured
26
- - `Integer` objects are now handled by the `format_object` method, which you can override to customise how various objects are rendered
27
- - You can now use `render` with `String` and `Method` objects
28
-
29
- ## [1.8.1] 2023-04-19
30
-
31
- ### Fixed
32
-
33
- - Rendering a component with a false `render?` predicate should return an empty String rather than `nil`.
34
-
35
- ## [1.8.0] 2023-04-19
36
-
37
- ### Changed
38
-
39
- - Support `Integer` and `Float` attribute values, and fall back to calling `to_str` on other objects.
40
-
41
- ## [1.7.0] 2023-04-18
42
-
43
- ### Added
44
-
45
- - Experimental Smart chunking.
46
-
47
- ### Changed
48
-
49
- - Improved YARD documentation, which is now available here https://rubydoc.info/gems/phlex
50
- - `SGML#render` can now render lambdas with zero or one arguments. Previously, it could only render lambdas with exactly one argument, although it could always render Procs with any number of arguments. When an argument is accepted, the `self` of the component rendering it is yielded to the Proc.
51
- - Raise an error when outputting an unknown object using `SGML#plain`.
52
- - Raise an error when using attribute keys that aren't Strings or Symbols.
53
- - Support Array and Set values for HTML/SVG attributes.
54
-
55
- ### Removed
56
-
57
- - Removed the `menuitem` element as it's a deprecated HTML element.
58
- - Removed the `SGML#text` method. This has been replaced with `SGML#plain`.
59
-
60
- ---
61
-
62
- Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex/releases).
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at joel@drapper.me. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/CONTRIBUTING.md DELETED
@@ -1,33 +0,0 @@
1
- # Contributing to Phlex
2
-
3
- ## Priorities
4
-
5
- We’re trying to provide the best possible developer experience for the people using Phlex in their apps and the best possible performance for the users of those apps.
6
-
7
- Phlex is incredibly complex and requires a lot of meta-programming but when you use it, it feels simple. Phlex views feel like plain old Ruby objects. You just subclass and define a couple of methods. That’s it. That’s how it should be.
8
-
9
- ## Setup
10
-
11
- - Install dependencies `bundle install`
12
- - Run the tests `bundle exec sus`
13
- - Run Rubocop and auto-correct `bundle exec rubocop -A`
14
-
15
- ## Tests
16
-
17
- New tests should be written using [GreenDots](https://github.com/joeldrapper/green_dots) and placed in the `gd` folder. You can run these tests with:
18
-
19
- ```
20
- bundle exec gd gd
21
- ```
22
-
23
- Joel maintains GreenDots itself, so if you run into any issues, please reach out to him by creating an issue in the GreenDots repo so he can improve the framework.
24
-
25
- Previously, we used **[Sus](https://github.com/ioquatix/sus)**. Sus tests are in the `test` folder and can be run with:
26
-
27
- ```
28
- bundle exec sus
29
- ```
30
-
31
- ## Documentation
32
-
33
- Documentation is deployed when it’s merged into the `latest` branch with a release. But you can build and preview the docs locally by running `bin/docs`.
data/Gemfile DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
-
6
- gemspec
7
-
8
- group :test do
9
- gem "sus"
10
- if RUBY_ENGINE == "ruby" && RUBY_VERSION[0] > "3"
11
- gem "async"
12
- end
13
- gem "concurrent-ruby"
14
- end
15
-
16
- group :development do
17
- gem "rubocop"
18
- gem "solargraph"
19
- gem "yard"
20
- gem "benchmark-ips"
21
- end
data/SECURITY.md DELETED
@@ -1,14 +0,0 @@
1
- # Security
2
-
3
- If you find a possible security vulnerability, please [send us a private advisory](https://github.com/phlex-ruby/phlex/security/advisories/new).
4
-
5
- > [!WARNING]
6
- > Please do not open a public Issue or Pull Request.
7
-
8
- ## Bug bounty
9
-
10
- There is currently a bounty of $100 USD, kindly sponsored by [Seth Horsley](https://twitter.com/SethHorsley), for the next serious vulnerability responsibly disclosed to us.
11
-
12
- ## Bug bounty pot
13
-
14
- If you wish to sponsor a bug bounty for Phlex, please get in touch with Joel at [joel@drapper.me](mailto:joel@drapper.me).
data/bench.rb DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "phlex"
5
- require "benchmark/ips"
6
-
7
- require_relative "fixtures/page"
8
- require_relative "fixtures/layout"
9
-
10
- puts RUBY_DESCRIPTION
11
-
12
- a = Example::Page.new.call
13
- # Example::Page.compile
14
- # Example::LayoutComponent.compile
15
- b = Example::Page.new.call
16
-
17
- raise unless a == b
18
-
19
- Benchmark.ips do |x|
20
- x.report("Page") { Example::Page.new.call }
21
- end
data/config/sus.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "phlex"
4
- require "bundler"
5
-
6
- Bundler.require :test
7
-
8
- require_relative "../fixtures/view_helper"
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Components::SayHi < Phlex::HTML
4
- def initialize(name, times: 1)
5
- @name = name
6
- @times = times
7
- end
8
-
9
- def template
10
- article {
11
- @times.times { h1 { "Hi #{@name}" } }
12
- yield
13
- }
14
- end
15
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Components
4
- extend Phlex::Kit
5
-
6
- autoload :SayHi, "components/say_hi"
7
- end
data/fixtures/layout.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Example
4
- class LayoutComponent < Phlex::HTML
5
- def initialize(title: "Example")
6
- @title = title
7
- end
8
-
9
- def view_template(&block)
10
- html do
11
- head do
12
- title { @title }
13
- meta name: "viewport", content: "width=device-width,initial-scale=1"
14
- link href: "/assets/tailwind.css", rel: "stylesheet"
15
- end
16
-
17
- body class: "bg-zinc-100" do
18
- nav class: "p-5", id: "main_nav" do
19
- ul do
20
- li(class: "p-5") { a(href: "/") { "Home" } }
21
- li(class: "p-5") { a(href: "/about") { "About" } }
22
- li(class: "p-5") { a(href: "/contact") { "Contact" } }
23
- end
24
- end
25
-
26
- div class: "container mx-auto p-5", &block
27
- end
28
- end
29
- end
30
- end
31
- end
data/fixtures/page.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Example
4
- class Page < Phlex::HTML
5
- def view_template
6
- render LayoutComponent.new do
7
- h1 { "Hi" }
8
-
9
- 100.times do
10
- table id: "test", class: "a b c d e f g" do
11
- tr do
12
- td id: "test", class: "a b c d e f g" do
13
- span { "Hi" }
14
- end
15
-
16
- td id: "test", class: "a b c d e f g" do
17
- span { "Hi" }
18
- end
19
-
20
- td id: "test", class: "a b c d e f g" do
21
- span { "Hi" }
22
- end
23
-
24
- td id: "test", class: "a b c d e f g" do
25
- span { "Hi" }
26
- end
27
-
28
- td id: "test", class: "a b c d e f g" do
29
- span { "Hi" }
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewHelper
4
- def self.extended(parent)
5
- parent.class_exec do
6
- let(:output) { example.call }
7
- let(:example) { view.new }
8
- end
9
- end
10
-
11
- def view(&block)
12
- let :view do
13
- Class.new(Phlex::HTML, &block)
14
- end
15
- end
16
-
17
- def svg_view(&block)
18
- let :view do
19
- Class.new(Phlex::SVG, &block)
20
- end
21
- end
22
- end
data/gd/phlex/callable.rb DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Example
4
- include Phlex::Callable
5
-
6
- def call
7
- "Hello, world!"
8
- end
9
- end
10
-
11
- def example
12
- Example.new
13
- end
14
-
15
- test "to_proc" do
16
- expect(example.to_proc).to_be_a Proc
17
- expect(example.to_proc.call) == "Hello, world!"
18
- end
@@ -1,107 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- include TestHelper
4
-
5
- class ToPhlexAttributeValueable
6
- def to_phlex_attribute_value
7
- "to_phlex_attribute_value"
8
- end
9
- end
10
-
11
- class ToSable
12
- def to_s
13
- "to_s"
14
- end
15
- end
16
-
17
- class ToStrable
18
- def to_str
19
- "to_str"
20
- end
21
- end
22
-
23
- test "with symbol-keyed hash attributes" do
24
- component = build_component_with_template do
25
- div data: { name: { first_name: "Joel" } }
26
- end
27
-
28
- expect(component.new).to_render %(<div data-name-first-name="Joel"></div>)
29
- end
30
-
31
- test "with string-keyed hash attributes" do
32
- component = build_component_with_template do
33
- div data: { "name" => { "first_name" => "Joel" } }
34
- end
35
-
36
- expect(component.new).to_render %(<div data-name-first_name="Joel"></div>)
37
- end
38
-
39
- test "with an array of symbols and strings" do
40
- component = build_component_with_template do
41
- div class: ["bg-red-500", :rounded]
42
- end
43
-
44
- expect(component.new).to_render %(<div class="bg-red-500 rounded"></div>)
45
- end
46
-
47
- test "with a set of symbols and strings" do
48
- component = build_component_with_template do
49
- div class: Set.new(["bg-red-500", :rounded])
50
- end
51
-
52
- expect(component.new).to_render %(<div class="bg-red-500 rounded"></div>)
53
- end
54
-
55
- test "with a to_phlex_attribute_value-able object" do
56
- component = build_component_with_template do
57
- div class: ToPhlexAttributeValueable.new
58
- end
59
-
60
- expect(component.new).to_render %(<div class="to_phlex_attribute_value"></div>)
61
- end
62
-
63
- test "with a to_s-able object" do
64
- component = build_component_with_template do
65
- div class: ToSable.new
66
- end
67
-
68
- expect(component.new).to_render %(<div class="to_s"></div>)
69
- end
70
-
71
- test "with a to_str-able object" do
72
- component = build_component_with_template do
73
- div class: ToStrable.new
74
- end
75
-
76
- expect(component.new).to_render %(<div class="to_str"></div>)
77
- end
78
-
79
- test "with numeric integer/float" do
80
- component = build_component_with_template do
81
- input type: "range", min: 0, max: 10, step: 0.5
82
- end
83
-
84
- expect(component.new).to_render %(<input type="range" min="0" max="10" step="0.5">)
85
- end
86
-
87
- if RUBY_ENGINE == "ruby"
88
- context "with unique tag attributes" do
89
- let def component
90
- build_component_with_template do
91
- div class: SecureRandom.hex
92
- end
93
- end
94
-
95
- let def report
96
- component.call
97
-
98
- MemoryProfiler.report do
99
- 2.times { component.call }
100
- end
101
- end
102
-
103
- test "doesn't leak memory" do
104
- expect(report.total_retained) == 0
105
- end
106
- end
107
- end
data/gd/support/helper.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "phlex"
4
- require "bundler"
5
-
6
- Bundler.require :test
7
-
8
- module TestHelper
9
- def build_component_with_template(&block)
10
- Class.new(Phlex::HTML) { define_method(:template, &block) }
11
- end
12
- end
13
-
14
- module ToRender
15
- def to_render(expected_output)
16
- output = subject.call
17
- assert(output == expected_output) { "Expected `#{output.inspect}` to equal `#{expected_output.inspect}`." }
18
- end
19
- end
20
-
21
- GreenDots.configure do |config|
22
- config.register_matcher ToRender, Phlex::SGML
23
- end
data/phlex_logo.png DELETED
Binary file
data/sig/phlex.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Phlex
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end