Re: Spyce example
Bruce Webber <[email protected]>
| Newsgroups | gmane.comp.python.spyce.general |
|---|---|
| Message-ID | <BBCC1DFB7031E0D31857944E@[192.168.1.100]> |
--Jonathan Ellis <[email protected]> wrote: > Cool! That's the sort of thing I hoped to see active tags used for. Thanks - I'm glad you like the example. I find that tags good for any HTML elements that will be repeated on all pages. By abstracting them into the tag file maintenance is easier and the HTML code is more readable (it's more semantic). > (Personally I would put the html generation part of writeLinkHTML in the > .spi, but whatever floats your boat. :) I agree - that keeps HTML out of .py files (better separation of content, presentation and code). So I changed the writeNavHTML tag to the following: [[.begin name=writeNavHTML singleton=True ]] [[.attr name=currpage ]] [[\ # navigation links tNavLinks = (('Home', 'index.spy'), ('Technology', 'tech.spy'), ('License', 'license.spy'), ('Contact', 'contact.spy'), ('Trac (Source Code Management)', 'http://trac.karda.org')) def writeLinkHTML(sCurrPage): sHTML = '<ul>\n' for tLink in tNavLinks: if tLink[0] == sCurrPage: sHTML += '<li class="current">' + tLink[0] + '</li>\n' else: sHTML += ('<li><a href="' + tLink[1] + '">' + tLink[0] + '</a></li>\n') sHTML += '</ul>\n' return sHTML ]] <div id="navbox"> [[=writeLinkHTML(currpage) ]] </div> [[.end]] Now the tag file no longer needs to import the .py file. I also renamed the tag file so it has the .spi extension. -- Bruce Webber [email protected] http://brucewebber.us ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642