Closed prajapatisagar closed 5 years ago
I think the issue is more that __()
is used in the save function.
edit
and save
don't need to be the same, would be impossible anyway.
@swissspidy If edit
and save
content is not same then it will throw an error after update the page.
I think you're confusing two things here, @prajapatisagar. The validation you are talking about makes sure that, when editing a block on the backend, the save always generates the same output for a same set of attributes/props.
The methods here are named in a misleading way. This is actually something like this:
edit()
=> "how to render on the backend (with extra editing controls)save()
=> "how to render on the frontend (HTML sent to visitors)If they would need to be the same, there would be no reason to have two of them.
@gziolo Can you confirm my above interpretation?
That being said, the __()
is indeed problematic, as it could invalidate the block through outside interference.
The methods here are named in a misleading way. This is actually something like this:
edit()
=> "how to render on the backend (with extra editing controls)save()
=> "how to render on the frontend (HTML sent to visitors)If they would need to be the same, there would be no reason to have two of them.
Yes, it's the correct explanation. It's more complex, but the idea is that save
is used to generate HTML saved in the post_content
of the post. edit
is way more complex because it contains all the UI elements necessary to edit the content and its rendered in the block editor.
I'm closing this PR, @prajapatisagar, as I don't think it is solving any problem, at least not the one you're expecting to solve. If there is an actual reproducible issue that this was meant to solve, please reopen/add comment.
If Edit and save content not the same then it will show an error after refresh the editor.