Skip to content

Commit

Permalink
And we need that same fix for text too
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Apr 6, 2024
1 parent 32abf19 commit b5d7e5b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [0.5.2] - 2024-04-06

- And we need that same fix for `text` too

## [0.5.1] - 2024-04-06

- Fix logic bug in `html`
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
streamlined (0.5.1)
streamlined (0.5.2)
serbea (>= 2.1)
zeitwerk (~> 2.5)

Expand Down
14 changes: 8 additions & 6 deletions lib/streamlined/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module Helpers
module TouchableProc
attr_accessor :touched

def self.run_through_pipeline(in_context_binding, input, callback)
Serbea::Pipeline.new(in_context_binding, input).tap { _1.instance_exec(&callback) }.then do |pipeline|
-> { pipeline.value }
end
end

def touch
self.touched = true
self
Expand Down Expand Up @@ -79,7 +85,7 @@ def attribute_segment(attr, value)
end

def text(callback, piping = nil)
callback = Serbea::Pipeline.new(binding, callback).tap { _1.instance_exec(&piping) } if piping
callback = TouchableProc.run_through_pipeline(binding, callback, piping) if piping

(callback.is_a?(Proc) ? callback.touch : callback).to_s.then do |str|
next str if str.html_safe?
Expand All @@ -89,11 +95,7 @@ def text(callback, piping = nil)
end

def html(callback, piping = nil)
if piping
callback = Serbea::Pipeline.new(binding, callback).tap { _1.instance_exec(&piping) }.then do |pipeline|
-> { pipeline.value }
end
end
callback = TouchableProc.run_through_pipeline(binding, callback, piping) if piping

callback.html_safe.touch
end
Expand Down
2 changes: 1 addition & 1 deletion lib/streamlined/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Streamlined
VERSION = "0.5.1"
VERSION = "0.5.2"
end

0 comments on commit b5d7e5b

Please sign in to comment.