phlex 1.0.0.rc1 → 1.0.0.rc2
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.
Potentially problematic release.
This version of phlex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/phlex/helpers.rb +23 -12
- data/lib/phlex/html.rb +13 -14
- data/lib/phlex/version.rb +1 -1
- data/lib/phlex.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 72f6baa9bd23ce981517a40897f2bb63a1cbd60fbc87bb127883e8eeb36cc302
         | 
| 4 | 
            +
              data.tar.gz: 5abc8c59a81cdff51f5da9250a28d9cc42308b467aa662b155fb1d28eca4a1c2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8db8f9df3da1f218bd2029ea22414ea53a910de8b1810d71c70a0e9022a1353dd69557c91eb1ffee5355733c0d8d6878aae9379a75ee0eaa76d05c6ee20abb8e
         | 
| 7 | 
            +
              data.tar.gz: 8027722c6fd1592c86f5fa6150814206a007c12a810985c72231195dcb0089aa34fd91a5addbeb9c14a8137a5a2f3fe984c07f554ee6504a4b4c25d6dd216046
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/lib/phlex/helpers.rb
    CHANGED
    
    | @@ -5,27 +5,38 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0") | |
| 5 5 | 
             
            end
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Phlex::Helpers
         | 
| 8 | 
            -
            	private
         | 
| 9 | 
            -
             | 
| 10 8 | 
             
            	def tokens(*tokens, **conditional_tokens)
         | 
| 11 9 | 
             
            		conditional_tokens.each do |condition, token|
         | 
| 12 | 
            -
            			case condition
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
            				"The class condition must be a Symbol or a Proc."
         | 
| 10 | 
            +
            			truthy = case condition
         | 
| 11 | 
            +
            				when Symbol then send(condition)
         | 
| 12 | 
            +
            				when Proc then condition.call
         | 
| 13 | 
            +
            				else raise ArgumentError, "The class condition must be a Symbol or a Proc."
         | 
| 17 14 | 
             
            			end
         | 
| 18 15 |  | 
| 19 | 
            -
            			 | 
| 20 | 
            -
             | 
| 16 | 
            +
            			if truthy
         | 
| 17 | 
            +
            				case token
         | 
| 18 | 
            +
            					when Hash then _append_token(tokens, token[:then])
         | 
| 19 | 
            +
            					else _append_token(tokens, token)
         | 
| 20 | 
            +
            				end
         | 
| 21 | 
            +
            			else
         | 
| 22 | 
            +
            				case token
         | 
| 23 | 
            +
            					when Hash then _append_token(tokens, token[:else])
         | 
| 24 | 
            +
            				end
         | 
| 25 | 
            +
            			end
         | 
| 26 | 
            +
            		end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            		tokens.join(" ")
         | 
| 29 | 
            +
            	end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            	def _append_token(tokens, token)
         | 
| 32 | 
            +
            		case token
         | 
| 33 | 
            +
            			when nil then nil
         | 
| 21 34 | 
             
            			when String then tokens << token
         | 
| 35 | 
            +
            			when Symbol then tokens << token.name
         | 
| 22 36 | 
             
            			when Array then tokens.concat(token)
         | 
| 23 37 | 
             
            			else raise ArgumentError,
         | 
| 24 38 | 
             
            				"Conditional classes must be Symbols, Strings, or Arrays of Symbols or Strings."
         | 
| 25 | 
            -
            			end
         | 
| 26 39 | 
             
            		end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            		tokens.compact.join(" ")
         | 
| 29 40 | 
             
            	end
         | 
| 30 41 |  | 
| 31 42 | 
             
            	def classes(*tokens, **conditional_tokens)
         | 
    
        data/lib/phlex/html.rb
    CHANGED
    
    | @@ -183,14 +183,13 @@ module Phlex | |
| 183 183 | 
             
            		end
         | 
| 184 184 |  | 
| 185 185 | 
             
            		def text(content)
         | 
| 186 | 
            -
            			 | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
            			end
         | 
| 186 | 
            +
            			@_target << ERB::Util.html_escape(
         | 
| 187 | 
            +
            				case content
         | 
| 188 | 
            +
            					when String then content
         | 
| 189 | 
            +
            					when Symbol then content.name
         | 
| 190 | 
            +
            					else content.to_s
         | 
| 191 | 
            +
            				end
         | 
| 192 | 
            +
            			)
         | 
| 194 193 |  | 
| 195 194 | 
             
            			nil
         | 
| 196 195 | 
             
            		end
         | 
| @@ -264,11 +263,11 @@ module Phlex | |
| 264 263 | 
             
            			if unchanged
         | 
| 265 264 | 
             
            				case content
         | 
| 266 265 | 
             
            				when String
         | 
| 267 | 
            -
            					@_target <<  | 
| 266 | 
            +
            					@_target << ERB::Util.html_escape(content)
         | 
| 268 267 | 
             
            				when Symbol
         | 
| 269 | 
            -
            					@_target <<  | 
| 268 | 
            +
            					@_target << ERB::Util.html_escape(content.name)
         | 
| 270 269 | 
             
            				when Integer, Float
         | 
| 271 | 
            -
            					@_target <<  | 
| 270 | 
            +
            					@_target << ERB::Util.html_escape(content.to_s)
         | 
| 272 271 | 
             
            				end
         | 
| 273 272 | 
             
            			end
         | 
| 274 273 |  | 
| @@ -309,13 +308,13 @@ module Phlex | |
| 309 308 | 
             
            				when true
         | 
| 310 309 | 
             
            					buffer << " " << name
         | 
| 311 310 | 
             
            				when String
         | 
| 312 | 
            -
            					buffer << " " << name << '="' <<  | 
| 311 | 
            +
            					buffer << " " << name << '="' << ERB::Util.html_escape(v) << '"'
         | 
| 313 312 | 
             
            				when Symbol
         | 
| 314 | 
            -
            					buffer << " " << name << '="' <<  | 
| 313 | 
            +
            					buffer << " " << name << '="' << ERB::Util.html_escape(v.name) << '"'
         | 
| 315 314 | 
             
            				when Hash
         | 
| 316 315 | 
             
            					_build_attributes(v.transform_keys { "#{k}-#{_1.name.tr('_', '-')}" }, buffer: buffer)
         | 
| 317 316 | 
             
            				else
         | 
| 318 | 
            -
            					buffer << " " << name << '="' <<  | 
| 317 | 
            +
            					buffer << " " << name << '="' << ERB::Util.html_escape(v.to_s) << '"'
         | 
| 319 318 | 
             
            				end
         | 
| 320 319 | 
             
            			end
         | 
| 321 320 |  | 
    
        data/lib/phlex/version.rb
    CHANGED
    
    
    
        data/lib/phlex.rb
    CHANGED
    
    
    
        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.0.0. | 
| 4 | 
            +
              version: 1.0.0.rc2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Joel Drapper
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-11- | 
| 11 | 
            +
            date: 2022-11-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: zeitwerk
         |