Skip to content

Commit

Permalink
Add compatibility fixes re: Streamlined
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Apr 18, 2024
1 parent fd53007 commit cb3ac56
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.15.0] - 2024-04-17

- Add compatibility fixes re: Streamlined

## [0.14.0] - 2024-03-03

- Add Rodauth support in Bridgetown
Expand Down
66 changes: 32 additions & 34 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lifeform (0.14.0)
lifeform (0.15.0)
hash_with_dot_access (>= 1.2)
sequel (>= 5.72)
streamlined (>= 0.2.0)
Expand All @@ -10,7 +10,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.1)
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand All @@ -23,41 +23,40 @@ GEM
ansi (1.5.0)
ast (2.4.2)
backport (1.2.0)
base64 (0.1.1)
benchmark (0.2.1)
bigdecimal (3.1.4)
base64 (0.2.0)
benchmark (0.3.0)
bigdecimal (3.1.7)
builder (3.2.4)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
diff-lcs (1.5.0)
drb (2.1.1)
ruby2_keywords
diff-lcs (1.5.1)
drb (2.2.1)
e2mmap (0.1.0)
erubi (1.12.0)
hash_with_dot_access (1.2.0)
activesupport (>= 5.0.0, < 8.0)
i18n (1.14.1)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.6)
json (2.6.3)
json (2.7.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
minitest (5.20.0)
minitest (5.22.3)
minitest-reporters (1.6.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mutex_m (0.1.2)
nokogiri (1.15.4-arm64-darwin)
mutex_m (0.2.0)
nokogiri (1.16.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
Expand All @@ -66,37 +65,36 @@ GEM
minitest
nokogiri (>= 1.6)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.8.2)
rake (13.2.1)
regexp_parser (2.9.0)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.6)
rubocop (1.57.2)
rubocop (1.63.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-bridgetown (0.4.1)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-bridgetown (0.5.0)
rubocop (~> 1.23)
rubocop-performance (~> 1.12)
rubocop-minitest (0.20.1)
rubocop (>= 0.90, < 2.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sequel (5.74.0)
sequel (5.79.0)
bigdecimal
serbea (2.1.0)
erubi (>= 1.10)
Expand All @@ -116,16 +114,16 @@ GEM
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
streamlined (0.3.1)
streamlined (0.5.2)
serbea (>= 2.1)
zeitwerk (~> 2.5)
thor (1.3.0)
thor (1.3.1)
tilt (2.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
yard (0.9.34)
zeitwerk (2.6.12)
yard (0.9.36)
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-21
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lifeform

Component-centric form object rendering for Ruby. Rails and Bridgetown both supported.
Component-centric form object rendering for Ruby. Bridgetown, Roda, and Rails all supported.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion lib/lifeform/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def template(&block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComple
form_tag = library::FORM_TAG
parameters[:action] ||= url || (model ? helpers.send(self.class.const_get(:MODEL_PATH_HELPER), model) : nil)

html -> { <<~HTML # rubocop:disable Bridgetown/HTMLEscapedHeredoc
html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
<#{form_tag} #{html_attributes attributes}>
#{add_authenticity_token unless parameters[:method].to_s.casecmp("get").zero?}
#{@method_tag&.() || ""}
Expand Down
8 changes: 4 additions & 4 deletions lib/lifeform/libraries/default/button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def template(&block)
return "" if !@if.nil? && !@if

button_tag = dashed self.class.const_get(:BUTTON_TAG)
label_text = block ? capture(self, &block) : @label.is_a?(Proc) ? @label.pipe : @label # rubocop:disable Style/NestedTernaryOperator
label_text = block ? capture(self, &block) : @label

field_body = html -> { <<~HTML # rubocop:disable Bridgetown/HTMLEscapedHeredoc
<#{button_tag}#{html_attributes @attributes, prefix_space: true}>#{text -> { label_text }}</#{button_tag}>
field_body = html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
<#{button_tag}#{html_attributes @attributes, prefix_space: true}>#{text label_text}</#{button_tag}>
HTML
}

return field_body unless self.class.const_get(:WRAPPER_TAG)

wrapper_tag = dashed self.class.const_get(:WRAPPER_TAG)
html -> { <<~HTML # rubocop:disable Bridgetown/HTMLEscapedHeredoc
html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
<#{wrapper_tag} #{html_attributes name: @attributes[:name]}>#{field_body}</#{wrapper_tag}>
HTML
}
Expand Down
8 changes: 4 additions & 4 deletions lib/lifeform/libraries/default/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def model_name
def value_for_model = @model.send(attributes[:name])

def handle_labels
label_text = attributes[:label].is_a?(Proc) ? attributes[:label].pipe : attributes[:label]
label_text = attributes[:label]
label_name = (attributes[:id] || attributes[:name]).to_s

@attributes = attributes.filter_map { |k, v| [k, v] unless k == :label }.to_h

-> { <<~HTML
<label for="#{text -> { label_name }}">#{text -> { label_text }}</label>
<label for="#{text -> { label_name }}">#{text label_text}</label>
HTML
}
end
Expand All @@ -58,7 +58,7 @@ def template(&block) # rubocop:disable Metrics/AbcSize
input_tag = dashed self.class.const_get(:INPUT_TAG)
closing_tag = input_tag != "input"

field_body = html -> { <<~HTML # rubocop:disable Bridgetown/HTMLEscapedHeredoc
field_body = html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
#{html(@label || -> {}).to_s.strip}
<#{input_tag} #{html_attributes type: @field_type.to_s, **@attributes}>#{
"</#{input_tag}>" if closing_tag
Expand All @@ -70,7 +70,7 @@ def template(&block) # rubocop:disable Metrics/AbcSize
return field_body unless self.class.const_get(:WRAPPER_TAG)

wrapper_tag = dashed self.class.const_get(:WRAPPER_TAG)
html -> { <<~HTML # rubocop:disable Bridgetown/HTMLEscapedHeredoc
html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
<#{wrapper_tag} #{html_attributes name: @attributes[:name]}>#{field_body.to_s.strip}</#{wrapper_tag}>
HTML
}
Expand Down
2 changes: 1 addition & 1 deletion lib/lifeform/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Lifeform
VERSION = "0.14.0"
VERSION = "0.15.0"
end
2 changes: 1 addition & 1 deletion test/test_lifeform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestForm < Lifeform::Form

class TestAutolayout < Lifeform::Form
field :first_name, label: "<b>First Name</b>".html_safe, required: true
field :last_name, label: -> { "Last Name" }, goof: "<em>Wow</em>"
field :last_name, label: -> { "Last Name".html_safe }, goof: "<em>Wow</em>"
field :age, library: :shoelace, label: "Your Age"

field :submit, type: :submit_button, label: "<i>Save</i>".html_safe, class: "font-bold"
Expand Down

0 comments on commit cb3ac56

Please sign in to comment.