SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jun 21, 2006, 08:39 #1
Help with a customization problem
I think that's the best way to put it.
I have a string I'm outputting that is built with this line:
Code:custom_box_score_school(box_score.team.school)+box_score.first.to_s+"\t"+box_score.second.to_s+"\t"+box_score.third.to_s+"\t"+box_score.fourth.to_s+"\t"+box_score.final_score.to_s
Code:1st 2nd 3rd 4th Final Montana 7 7 14 7 35 Michigan 0 0 7 7 14
This certainly has many, many solutions. I'm having some problems coming up with any good ones. Some considerations:
1) The customization will be saved and applied to all future output. Basically the user should be able to create this customized look and it will be used again in other games outputs (this example is for American football box scores so there are other games outputs that will be generated).
2) Following from above this customization should be able to be applied to any and all future box score outputs as a template.
3) The solution should be flexible enough to allow it to be used to allow users to customize other types of output like collections (that will be loops for outputting).
My current thought is to have the user create a psuedo code string with placeholders for the AR objects attributes and somehow applying this to the above code example. Not sure how to go about this best though. Also not sure this is the best way to do it. I feel like I'm missing some Ruby magic that would allow me to do this better. Maybe using some sort of decorator pattern for the AR object to alter it's output? The dynamic nature of AR objects though makes this tricky for me and I'm not sure how to proceed. Any and all suggestions and help are greatly appreciated. Thanks.Erh
-
Jun 21, 2006, 10:42 #2
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Liquid templates are for you!
The website seems to be down now, but anyway:
http://home.leetsoft.com/liquid
It's a template language designed for users of your application, rather than programmers.
-
Jun 21, 2006, 12:23 #3
Do they replace rhtml as the templating then for the whole site or could I use these for just this situation?
Erh
-
Jun 22, 2006, 00:31 #4
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can use rhtml and liquid templates together in one site. I think you can even use rhtml for a layout and liquid templates for a page-specific template.
-
Jun 22, 2006, 04:03 #5
It's exactly what I was looking for and more. Thanks for the help.
Erh
Bookmarks