Hi, I''m developing a mini-programming language for research surveys.
[code]
question S1 {
label: The first few questions are just to help us categorize you.
label: Do you or does any member in your household work for... (MARK
ONE ONLY FOR EACH.)
grid {
col {
1 Yes
2 No
}
row {
1 An advertising agency
2 A public relations company
3 A marketing research firm or department
4 An office products company
5 A manufacturer or retailer of writing instruments
6 A manufacturer of packaging or adhesives
}
}
}
invalid if in("THISQUESTION","1")
[/code]
I''d like to use .rhtml-style codes for pre-processing macros like this:
[code]
<% specialQuestions.each do |q| %>
question <%= q.name %> {
label: Where do you purchase writing instruments like <%= q.type
%> for use at home, school or your office? (MARK ALL THAT APPLY.)
multiple {
1 Office products super stores such as Staples, Office Depot, or
Office Max.
2 Office supply catalogs such as Viking, Corporate Express, Boise,
Staples, Office Depot, or Office Max catalogs
3 Other
}
}
<% end %>
[/code]
(You can see how useful this feature would be for a large survey. One
could build hundreds of similar questions from small chunks of code.)
If the compile phase was in the controller, I could just do:
[code]
@script = render_to_string(:inline => @script)
[/code]
But that doesn''t work if I''m in the model, right? How can I
render a
document to a string while in the model?
--
Posted via http://www.ruby-forum.com/.