Find and Replace
This weekend I was testing the new _template_ feature of the recent Blocs api update. It's really impressive how fast the previews/exports are built. I made this Find and Replace bric (FAR) that modifies a custom .js file and let's you find and replace words and phrases across a whole page or your entire site.
Note that if you can edit the content reasonably quick then don't reach for this Bric in production. However at the very least there are some cases where it's probably going to come in handy by allowing content managers on larger Blocs sites to catch the instances of spelling and grammar errors and make global updates.
Current Version: v1.2 - 3/30/19
We've updated our website please visit us at https://blochead.dev
What are some use cases for FAR?
- Add and remove copyright and trademark symbols.
- Adding words or phrases to your content with the option to revert to the original very easily.
- Use FAR to highlight instances of a word or phrase for review and editorial purposes.
- Highlight certain words for your audience.
Frequently Asked Questions
Is the "find" case sensitive?
Yes, the search is case sensitive. It also includes punctuation and spacing.
What do the _Target_ options do?
- You can choose to find and replace across the entire body of the page or use the "class" option to limit your findings to areas of the page that have the class ".far" applied applied to them.
- Make a class called "far" using the blocs class editor. Apply it to a bloc and choose "class" in the Target dropdown.
What is the _Highlighter_ option?
Use this feature to highlight the text that has changed so that it's easier to find your change and check your work. Turn off highlighting before you export your site.
What does the magnifying glass mean?
If you see the magnifying glass you have not entered enough a required field. Check that you have a find and replace value. Important!: An empty field is not the same as a blank space!
Explain "empty field" vs "blank space".
An empty field has no spaces (think space bar). A blank space is where you've pushed the space bar and then previewed/exported the page. The FAR bric will both match and replace blank spaces.
Can I use this bric across all my pages?
Sure, just add it to one of Blocs app global areas.
Why only 5 strings?
There's a current bug that @Norm is aware of which doesn't allow more options viewed in the custom bric's sidebar. When this is fixed I may up the number, although probably not by too much.
How many F.A.R brics can I use per page?
You can only use one (1) FAR bric per page. However the bric supports finding and replacing up to five strings. _Place bric in global areas for all pages._
I see strange behavior in the preview. Why? What do I do?
- Find and replace has some rules to follow. FAR doesn't actually change your content in Blocs app. It makes these changes at page load. Your original contact is still in tact. If you reset the bric's options or remove the bric you'll see the page remains how you left it.
- FAR is almost too powerful. It will find classes and let you type characters that could break your code. But none of this is permanent. It's always easy to reset an option or remove the bric and everything is fine again.