Click to See Complete Forum and Search --> : Script to create Web Page Templates?


PravusMentis
03-31-2002, 11:54 PM
Heres the deal most of my work is dealing with websites and intranets etc. I use PHP, HTML, MySQL, Javascript etc. Now I make lots of pages and it gets tiring repeatedly writing things such as <HTML>, <HEAD> and other required tags.

What I want to do is create a script that when executed gives me several options
1. PHP Template
2. PHP/MySQL Template
3. HTML Template

And from there an IF $variable will be used to call up the appropriate function which'd be the default code commonly used for such pages. For the MySQL Template i'd also have several inputs for database, name, and password which'd be variables also.

Question is after all that is done how can I get it to print it out into a text editor?

I can easily do such a script for a website to just echo out the final result but I want it in this case to print out the final results in a text editor so i same some time writing out tags.

Next which language should I use for such a program? I'm fine in PHP, and semi proficient in C++ along with Perl.

[ 31 March 2002: Message edited by: PravusMentis ]

Stuka
04-01-2002, 12:30 AM
I'm not sure about spitting it into a text editor (though vim MAY except STDIN as a 'file' input name -- many programs do this if you use '-' (without quotes of course) where the file argument is - if so, you could redirect the output of the script to vim. If not, you could always pipe the output to a file. If you do this, it will be no more difficult than what you already know - the output to a web browser is just STDOUT, which is what you're redirecting to a file!

PravusMentis
04-01-2002, 06:00 PM
Thanks. But what language should I use for this? I love PHP but can I create a script like this in PHP and run it in a console? Or should I use Perl or C/C++?

Stuka
04-01-2002, 06:52 PM
AFAIK, php is strictly useful in web applications (it outputs HTTP headers and the like, which would gum up the works of a template...). Perl, on the other hand, should work beautifully here.

takshaka
04-02-2002, 01:06 AM
You can use PHP as a regular scripting language if you have the standalone interpreter installed. But...

Strike
04-02-2002, 02:40 AM
For vim:

Create your skeleton file (I will refer to it as ~/.vim-files/skel.html).
Put the following in your ~/.vimrc:

autocmd BufNewFile *.htm,*.html 0r ~/.vim-files/skel.html

Voila, every time you start up a new .htm or .html file, it will insert all that stuff in there for you.

PravusMentis
04-02-2002, 09:54 AM
Ah thanks, that helps