CodeSmith Community
Your Code. Your Way. Faster!

Is anyone else programmatically creating then compiling templates?

Latest post 04-30-2007 9:05 AM by pwelter34. 1 replies.
  • 04-25-2007 3:27 PM

    • ript
    • Not Ranked
    • Joined on 04-24-2007
    • TN, USA
    • Posts 1
    • Points 35

    Is anyone else programmatically creating then compiling templates?

    I'm going to try generating merge-strategy enabled subtemplate hierarchies based on metadata (xsd). Has anyone else attempted this? Pitfalls? Tips? I've only been using codesmith for 20 days now; so, please stop me if this is absolutely crazy.

    So far I'm generating and compiling a single subtemplate. I'll be willing to post code once I clean it up a little more. If I am being unclear, _please_ tell me to expound!

    Plans:

    1. Also generate template (parent) that renders subtemplate (child).
    2. Set subtemplate (child) properties inside generated template (parent) based on metadata.
    3. Extend to generating multiple subtemplates (many children).
    4. Extend to generating multiple templates (parents) running common subtemplates (many-to-many).
    5. Extend to allow subtemplates to have subtemplates.... (N levels)
    6. Rinse, revisit metadata type, revisit codesmith architecture via reflection, revisit "code sharing techniques"
    that's right, another ambitious newb
    • Post Points: 35
  • 04-30-2007 9:05 AM In reply to

    • pwelter34
    • Top 25 Contributor
    • Joined on 03-13-2003
    • Eden Prairie, MN
    • Posts 255
    • Points 749,915

    Re: Is anyone else programmatically creating then compiling templates?

    Here is syntax for using sub-templates.

    <%@ Register Name="SubTemplate" Template="SubTemplate.cst" %>

    <script runat="template">

    void RunChild()
    {
        SubTemplate sub = this.Create<SubTemplate>();
        sub.RenderToFile("file.txt", true);

    </script> 

    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems