template library

Discussion in 'Javascript' started by Lee, Nov 4, 2006.

  1. Lee

    Lee Guest

    Hi, I have a template file that looks something like this

    <tr>
    <td>{var1}</td>
    <td>{var2}</td>

    <td>
    <table>
    <tr>
    <td>Name: {name3}</td>
    <td>Age: {age3}</td>
    </tr>
    </table>
    </td>

    </tr>

    And I have a small javascript function that opens the template file
    above, replaces the variables with values in a hash, and returns the
    html in a string. Then, I put it into a table as a new row by just
    adding it to the tbody string.
    Works beautifully... in Firefox. In other browsers like IE 6, I think
    I need to use functions like table.addrow() and table.addcell(). These
    functions are compatible with other new browsers as far as I know and
    so this would be what I want to use.

    My question is, how would I do this if I want to start with the
    template file? The reason I want a template like this is that I also
    have server side scripts using it, and I figure it's the best way for
    javascript and php to use a template from the same source.

    I was thinking of parsing it using regex, finding each row and adding
    it individually, but I am not sure what the regex would be to find each
    individual row. And I am not sure if I can simply add a table without
    a function similar to table.addrow().

    Any help would be appreciated.
    Lee, Nov 4, 2006
    #1
    1. Advertising

  2. Lee

    Lee Guest

    Hi,
    Has anyone thought of something for this? I really would like some
    help..
    Lee, Nov 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Theis
    Replies:
    2
    Views:
    467
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    534
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,104
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    770
    Thomas J. Gritzan
    Oct 26, 2008
  5. nguillot
    Replies:
    5
    Views:
    530
Loading...

Share This Page