Reply to Re: Any html template framework or tools ? (urgent)

Your name:

Reply:


Posted by Googy on 03/02/07 21:33

def readFile(filename)
return "" if not File.exists?(filename)
contents = ""
begin
file = File.new(filename)
while(line = file.readline)
contents += line
end
rescue EOFError
file.close
end
return contents
end

def gen (infile)
incontents = readFile(infile)
markers = []
incontents.scan(/<<(.*?)>>/) {|filename| markers << filename.to_s}
for filename in markers
markcon = gen(filename)
incontents = incontents.gsub(Regexp.new('<<'+filename+">>"),
markcon) if not markcon.nil?
end

return incontents
end

def process (infile)
outfile =""
infile.scan(/(.*?).tel/){|outname| outfile = outname.to_s+".html"}
puts "Output file: "+outfile
ofile = File.new(outfile, "w")
ofile << gen(infile)
ofile.close
end


Here is simple ruby code that I came up with in 1 hr. It just saved
lot of time for me. It can't handle recursive file includes.

File include syntax "<<include file name>>"

just give the input filename to process function.

Thanks anyways.

Bye.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация