Free Bric: 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 grammer errors and make global updates.

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.


Download - Find and Replace (FAR)

FAR.bex (61.7 KB)

===============================

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 FAR 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.

Also @Norm, one thing I’ve noticed about the new template feature in Blocs 3.1 is that previewing inside Blocs app is unreliable. It works sometimes but seems to have a caching issue after a couple previews it stops updating for me. I try using webkit dev tools but can’t force a hard refresh without restarting Blocs. Good news is that it always works for me in the browser preview. Not a bigger deal than the sidebar issue IMHO. :wink:

12 Likes

Congratulations @Whittfield, nice job creating and documenting this.

Something such as this might be handy as part of Blocs inherently for users.
As recently discussed in the following thread: :wink:

PS: Thanks also to Mr. Shokeen, I knew this reminded me of something. :–)

Man, this is really cool! Thanks for putting this together. :grinning:

I’m working on this :+1:

2 Likes

I’ve fixed up the in app preview issue with template API calls. This will be fixed up in todays patch update.

Im still working on the UI cropping issue :triumph:

Great Bric BTW!

1 Like

@Whittfield

Great work!

1 Like

Thanks a bunch @Norm, the new api template feature is brilliant, congrats!

1 Like

Thanks Eldar,
Likewise, you have contributed some great content to the Blocs community. Cheers to you sir!

You’re welcome @KBConcepts, glad it is useful to you!

Thanks @Whittfield, it’s a very good job.
Again, many thanks for sharing with the community.

2 Likes