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 9229191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:30:39+00:00 2026-06-18T05:30:39+00:00

I find myself constantly doing the same thing, using designers to create nice ui’s

  • 0

I find myself constantly doing the same thing, using designers to create nice ui’s then convert HTML/CSS to split across the asset pipeline and find and replace paths and css+js tags; updating everything to use the asset path. Is there something that automagically does this?

  • 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-06-18T05:30:40+00:00Added an answer on June 18, 2026 at 5:30 am

    To me, this situation just calls out loudly for sed. If you’re running Linux, Mac OS X, or another *nix, read on. (If your dev environment is Windows but you are deploying to *nix server where you can set up post-deploy scripts, this approach will still work there.)

    So your designer has access to your assets in local directories, and it’ll generate tags like <img src="images/logo.png">. But, in deployment you want to either replace those paths with ERB calls like <img src="<%= asset_path 'logo.png' %>">, or else change them to point at some external CDN with a tag like <img src="http://assets.mysite.com/logo.png">, right?

    Well, in either case, sed is your friend! Sed can (among other things) go through a file and apply regex substitutions to them in-place. In the ERB call situation (assuming you’ve already renamed your file to have an erb extension), you would run this command:

    $ sed -i 's/\(<img[^>]*src="\)images/\([^"]+\)\("[^>*]>\)/\1<%= asset_path \'\2\' %>\3/g' somefile.html.erb
    

    After running this command, somefile.html.erb will be using asset_path instead of manually specified image paths.

    The second case, where you are providing images on another server or maybe just from another path, is similar:

    $ sed -i 's/\(<img[^>]*src="\)images/\([^"]+\)\("[^>*]>\)/\1http:\/\/assets.mysite.com\/\2\3/g' somefile.html
    

    And Bob’s your uncle!

    One thing that’s annoying about these commands is that you have to run them on each and every file. Well, time for another UNIX utility to come to the rescue: find. This utility can run a script on a bunch of files in a directory tree:

    $ find dir/with/html -type f -name '*.html.erb' -exec sed 's/foo/bar/g' {} \;
    

    Now, if much of the above looks like ancient Latin to you (and you aren’t fluent in ancient Latin), you’ll want to go learn more about regular expressions, so that you can tweak the above commands to do the various different kinds of transformations you want. This is a pretty good guide to using sed and regular expressions that doesn’t assume much prior knowledge.

    Once you have a set of commands that does the right thing, save them to a shell script file. Then, just run that file whenever you need it, and it will do all the annoying work for you! That’s what makes learning all these obtuse commands worth it; they’re more work upfront than a nice GUI find & replace dialog, but the flexibility of what they do and the ability to bundle them up into scripts saves you time and annoyance in the long run.

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

Sidebar

Related Questions

I constantly find myself using this idiom in KO-based HTML templates: <!-- ko if:
I find myself using Resharper's convert to auto property refactoring a lot to remove
I find myself doing something like this constantly to pull GET args into vars:
I come from a c++ background and I find myself constantly doing this in
I constantly find myself sending .NET code snippets to other developers using MS outlook
I constantly find myself rewriting the same lines of code in the Firebug console
I have Visual Studio 2008 and I find myself constantly adding the same 3
I constantly find myself writing similar code like the example below: if (object[Object Name]
I find myself doing this repeatedy. $jq(button).filter(function(){ return this.id.match(/^user_(\d+)_edit$/); }).click(function(){ var matches = this.id.match(/^user_(\d+)_edit$/);
I find myself using this method a ton to perform actions based on a

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.