-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocks: Fix demo teaser markup, More block custom text #2828
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2828 +/- ##
==========================================
+ Coverage 33.78% 33.79% +0.01%
==========================================
Files 191 191
Lines 5692 5693 +1
Branches 997 998 +1
==========================================
+ Hits 1923 1924 +1
Misses 3189 3189
Partials 580 580
Continue to review full report at Codecov.
|
168b58e
to
79debcc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I'm doing something wrong but when refreshing the page, I lose the custom text (I see null) and the teaser option is not selected.
Hm, yes, I can confirm this too. One half of this issue (not being serialized correctly) is fixed in 3a45620 . But also, the "Null" text being shown stems from the fact that the PEG parser returns
Where this becomes more interesting is in how we align this with the PHP attributes behavior, where PHP only has the single concept of cc @dmsnell |
In 8483b8a , I opted to update the PEG grammar to return falsey as |
Also, it is fun to see that the test fixtures illuminate the issue, but only after the fix is applied 😆 (See |
blocks/api/serializer.js
Outdated
saveContent += '\n<!--noteaser-->'; | ||
} | ||
|
||
return saveContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was there any real change here other than the name of text
vs customText
? I ask because we changed the declarative return with an imperative mutating return 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only effective difference should be the change in name from text
to customText
yes. I thought I might have made an improvement by refactoring the template+ternary soup but... well, we've been around this block before and I really don't care enough one way or the other to argue it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't gripe if you make a change to prefer your style over mine in this case, but maybe there's a middle-ground.
const moreTag = text
? `<!--more ${ text }-->`
: '<!--more-->';
const noTeaserTag = noTeaser
? '<!--noteaser-->'
: '';
return compact( [ moreTag, noTeaserTag ] ).join( '\n' );
I'm a huge fan of ternaries (they are expressions and not statements like their cousins, the if
structure) but I do draw the line at nesting ternaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe there's a middle-ground.
Looks good to me. Updated in rebased 3ba6476 .
8713d36
to
3ba6476
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @aduth
5657253
to
3ba6476
Compare
This pull request seeks to resolve two issues with the More block:
core/more
block teaser. Currently, the teaser tag is treated as freeform content, causing a freeform block to be unintentionally inserted after the More tag in demo content.text
, correct:customText
)Testing instructions:
Verify that when viewing the demo, the more block is shown with custom "Keep on reading!" text, that selecting the More block reveals "Teaser" is checked in the block settings, and that no freeform block is shown following the More block. Check that setting custom text to the More block, saving and reloading respects the changes made.