From: Brian Candler Date: 2007-02-02T07:28:56+09:00 Subject: Re: Parsing text files with dynamic contents On Fri, Feb 02, 2007 at 06:35:21AM +0900, Andrea Maschio wrote: > Let's guess a simple example: i need to parse a text file, wityh variables > inside, and then output again the resulting text to a file or to screen. > > -------------start example text------------ > > hello, it is #{now}, your name is #{name} > > > -------------end example text------------ > > variables could be written also $var, or whatever else could be better. > > but obviously when i do > > file.each do |line| > puts line #here i need to do something to find the variable and > output the correct value > end > > How would you ruby experts do the correct parsing to output values instead > of the text content? Is there any class available that do this? Google for 'erb' and 'eruby'