R
R
rd962016-02-01 13:55:44
PHP
rd96, 2016-02-01 13:55:44

How do you edit a large number of site pages with monotonous code?

Let's say there is a site with a bunch of pages and subpages, menus and lists with files like id*.html(id1.html,id2.html,id3.html).
It is necessary to change these names and so on, at the moment I use Text Raplacer and a banal find-replace from sublime.
It seems very interesting to work with Linux commands through the terminal, there is a wider toolkit there.
What do you use for these purposes?
UPD Pull out the code of one menu and change it to include the file will not work, although the menu works the same way, but
in the code on one page there is a space here and there, but not on the other, so find and replace does not work.
PS!!! THE CODE IS NOT MY, THEY GIVE IT TO ME ONLY FOR EDIT

Answer the question

In order to leave comments, you need to log in

7 answer(s)
R
riot26, 2016-02-01
@riot26

If you have a lot of monotonous code - you blew up somewhere

D
Dmitry, 2016-02-01
@DP-Studio

If several pages have the same code, something in the conservatory is wrong and needs to be corrected. Template engines will save the father of Russian democracy - smarty, blade, twig (php) jade, handlebars (js). For styles preprocessors less, stylus, sass. To build the front, use builders (tars, webpack, elixir, your own gulp-lisaped, etc., whichever is more appropriate). Then you don't have to ask these questions. One of the main development rules is "The same piece of code should be written only once"

S
sim3x, 2016-02-01
@sim3x

Before using commands, you should master the magic of backup!
And the magic of the git, so that in case of problems to roll back
Find the phrase in the directory and subdirectories regardless of the case

$ grep -ir "some shit code" ./ 
./filepath1: Some shit code
./filepath2: SoMe Shit code

Same thing with regular expressions
stackoverflow.com/questions/6153152/bash-script-fi...
Replace all phrases in the file and create a backup file
Replace all phrases in files in this directory and create a backup
sed -i.bak s/Some shit code/Some code/g *

Z
Zlatoslav Desyatnikov, 2016-02-01
@pxz

In the same sublime there is Find in folder (it seems to be called something like that), there is also a text replacement.
If you are interested in a console solution, then read about sed .

S
sitev_ru, 2016-02-01
@sitev_ru

Monotonous code should be placed in one file or database... Then there will be no such problems...

K
Kirill Kublyakov, 2016-02-01
@Kublyakov

jade-lang.com
Each block is a separate file.
Let's say the header.jade file is the same for all pages, changing the text in the topics to the required one - it will change in all pages.
PS - I saw that in the existing code, the replacement should be carried out. Then yes, search with replacement.

V
Vladimir Sergeevich, 2016-02-01
@VladimirZhid

Use some IDE ... From free Netbeans, then you'll appreciate it. The main thing is that if you undertook to study the instrument, study it, otherwise you will abandon it once and for all. There is such a thing as refactoring, convenient work with replacements. Plus, if the layout is large, such things as a header, header, footer, sidebar and all the same elements can be included in the form of php, it helps a lot if you need a really large layout.
Dmitry has a good answer, I support

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question