SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    So I have an AR object called box_score with attributes that I'm outputting. The output could look like this (with additional calls to the above etc):

    Code:
    			1st	2nd	3rd	4th	Final
    
    Montana                 7	7	14	7	35
    
    Michigan                0	0	7	7	14
    This output is actually being generated to look exactly like the above with code box and all and is for posting on vBulletin like forums like this. What I'd like to do is allow my users to customize the appearance of this output by applying bbCode to any and all pieces of this output.

    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

  2. #2
    SitePoint Guru
    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.

  3. #3
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do they replace rhtml as the templating then for the whole site or could I use these for just this situation?
    Erh

  4. #4
    SitePoint Guru
    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.

  5. #5
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's exactly what I was looking for and more. Thanks for the help.
    Erh


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •