Generating html files

what the recommended way to generate static html files based on a
database structure, for example 1000 product pages.

i would like to specify s template and embed css styles.

i use rails 3.1

thanx

On Sep 19, 2:10pm, “Jochen Kchelin - 8frogs.de[email protected]
wrote:

what the recommended way to generate static html files based on a database
structure, for example 1000 product pages.

i would like to specify s template and embed css styles.

i use rails 3.1

thanx

I’d look into using factory girl.

http://rubygems.org/gems/factory_girl

Dan N.

“"Jochen Kächelin - 8frogs.de"” [email protected] wrote in post
#1022809:

what the recommended way to generate static html files based on a
database structure, for example 1000 product pages.

i would like to specify s template and embed css styles.

i use rails 3.1

thanx

erb templates are part of the ruby language, as is the ability to query
a database. So you can write a ruby program that creates an erb
template, and you can query the database to fill in values in the
template, and then write the results to a bunch of files.

Here is an example:

require ‘erb’
require ‘sqlite3’

template = ERB.new <<“END_OF_TEMPLATE”

<%= name %> div {color:blue;}
Name: <%= name %>
Color: <%= color %>
END_OF_TEMPLATE

db = SQLite3::Database.new( “my_db.db” )
table = “test”

db.execute( “select * from #{table}” ) do |row|
name, color = row

File.open("#{name}.html", “w”) do |f|
f.puts template.result(binding)
#binding gathers up the variables and their values

end

end

–output:–

hammer.html:

hammer div {color:blue;}
Name: hammer
Color: black