Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:00:19+00:00 2026-05-25T14:00:19+00:00

I have about 50 templates, and I would like to standardize whitespace on variables

  • 0

I have about 50 templates, and I would like to standardize whitespace on variables as follows —

Inputs: {{variable}}, {{ something  }}, {{  test  }}, etc.
Output: {{ variable }}, {{ something }}, {{ test }} # one space within inner bracket

How would I do this find and replace to all files within myproject/templates ? Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:00:20+00:00Added an answer on May 25, 2026 at 2:00 pm

    find /myproject/templates -type f | xargs sed -i 's/{{\s*\(\S*\)\s*}}/{{ \1 }}/g'

    Translation:

    find /myprojects/templates -type f will find all items in /myproject/templates that are regular files (as opposed to symlinks or directories).

    xargs sed -i s/FIND/REPLACE/g' will execute sed to edit each file in place (that is, it will replace the contents of the file with the edited version). It will search for the pattern FIND and replace it with REPLACE globally (that is, everywhere it appears on the line).

    The components of the FIND pattern:

    {{\s* = two open-braces followed by zero or more whitespace characters

    \(\S*\) = any non-whitespace characters. (This means your variable names cannot contain internal spaces.) The escaped parens will save those characters (which are your variable names) for use in the REPLACE pattern.

    \s*}} = zero or more whitespace characters followed by two close-braces.

    The components of the REPLACE pattern are two open-braces, a single space, the variable name we saved using \(\S*\), another space, and the two close-braces.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For debugging purposes, I would like to have a variable in all my templates
I have a question about templates. I would like to have a templated class
I would like to restyle a ContextMenu , but I have a question about
I would like my templates to be smarter about generating controllers. In my domain
Have you worked in WPF? If yes you might have kown about the templates
I'm about to launch a few online stores and I would like to share
I have the below question, and would like to know if I have interpreted
I have markup which I would like to remove/transform certain tags from, but retain
I have Joomla Version 1.6.3 installed on my web hosting provider. I would like
We are using Mustache templates and I would like to make a preview View

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.