From b5d7e5bab0589b3f581c8a709f970870fa8da327 Mon Sep 17 00:00:00 2001 From: Jared White Date: Sat, 6 Apr 2024 08:37:22 -0700 Subject: [PATCH] And we need that same fix for `text` too --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- lib/streamlined/helpers.rb | 14 ++++++++------ lib/streamlined/version.rb | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9f301..a1983bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/Gemfile.lock b/Gemfile.lock index 58b662f..b7d33ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - streamlined (0.5.1) + streamlined (0.5.2) serbea (>= 2.1) zeitwerk (~> 2.5) diff --git a/lib/streamlined/helpers.rb b/lib/streamlined/helpers.rb index 9d9a0a1..a759509 100644 --- a/lib/streamlined/helpers.rb +++ b/lib/streamlined/helpers.rb @@ -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 @@ -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? @@ -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 diff --git a/lib/streamlined/version.rb b/lib/streamlined/version.rb index 474db90..642938c 100644 --- a/lib/streamlined/version.rb +++ b/lib/streamlined/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Streamlined - VERSION = "0.5.1" + VERSION = "0.5.2" end