feat: add eq / in processors and make WhenRenderer whitespace-tolerant (#31)#32
Merged
feat: add eq / in processors and make WhenRenderer whitespace-tolerant (#31)#32
eq / in processors and make WhenRenderer whitespace-tolerant (#31)#32Conversation
…erant (#31) Equality predicates against bindings used to require the verbose `map:value=1,*=` idiom. Two new processors make the common single-value and multi-value match cases direct: {{post_raw.post_status|eq:trash}} # was: |map:trash=1,*= {{post_raw.post_status|in:trash,draft}} # was: |map:trash=1,draft=1,*= The `eq` / `in` processors return the input unchanged when the match holds, and an empty string otherwise. They compose with the rest of the pipeline and gate `feedwright/when` directly. Negative match is still expressed via `feedwright/when negate=true`, so we deliberately do not add `neq` / `not_in`. Bundled with this: WhenRenderer's truthiness check now uses `'' !== trim( $value )`, so a stray trailing space in the expression (common typo class — observed in real local testing) no longer flips the gate to always-true. - src/Bindings/Resolver.php: process_eq + process_in registered as built-in processors - src/Renderer/WhenRenderer.php: trim() before the empty check - blocks/_shared/processor-suggestions.js: eq / in surfaced in the | autocomplete with arg hints - Unit tests: eq / in equality, trim, list semantics, empty-arg edge - Integration tests: when block with eq sanity-checks trashed-post gating, and a regression test that whitespace-only expressions stay closed - docs/requirements.md §13.6.2 (whitespace tolerance) + §14.6.1 (processor table) - ja translation strings added
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31.
Summary
eq/inを追加。feedwright/whenの expression をmap:trash=1,*=のような冗長な書き方からeq:trash/in:trash,draftに置き換え可能。feedwright/whenの真偽判定を whitespace-tolerant に変更('' === trim($value))。式の末尾にうっかり半角スペースを入れて常に真扱いになる事故を防ぐ(実際のローカル検証で踏んだのを修正)。ビフォーアフター
eq/inは 入力が一致するときに入力をそのまま返し、違えば空文字列を返す。feedwright/whenの判定基準(非空 = 真)にそのまま乗る。負の判定はfeedwright/whenのnegateで済むのでneq/not_inは意図的に追加しない。Whitespace tolerance
WhenRenderer の判定が
'' !== $valueから'' !== trim( $value )に変わるので、Changes
src/Bindings/Resolver.php:process_eq/process_inを built-in processors に追加src/Renderer/WhenRenderer.php:判定行にtrim()を追加blocks/_shared/processor-suggestions.js:|autocomplete にeq/in追加(argHinttrash,trash,draft)tests/Unit/BindingResolverTest.php:eq / in の挙動・空白トリム・空リスト・チェーン整合tests/Integration/RenderTest.php:when ブロックでのeq:trashの sanity check と whitespace-only expression が空扱いになる regressiondocs/requirements.md§13.6.2(whitespace tolerance の言及) + §14.6.1(プロセッサ表)Test plan
|autocomplete にeq/inが出る{{post_raw.post_status|eq:trash}}の when 配下が trash 投稿でだけ出力される{{...|eq:trash}})が今は常に空扱いになるcomposer test:unit(80 passed)、wp-env tests (141 passed)、composer phpcs(29 passed)<mdf:deleted/>がトラッシュ済み 1 件にだけ出る(今回の修正前は 20 件全部に出ていた)関連
#27(
feedwright/whenブロック追加)の延長。eq/inプロセッサと組み合わせると mediba 削除通知の expression が読みやすくなる。