Not just another template system (with screencast) |
[eluser]philpalmieri[/eluser]
Not just another template system (with screencast) So we have been working on this template system that we are now sharing. We built it to separate not only the design from the application, but the designers themselves. Follow with me for a minute: we use a cascading template that includes main outer templates, header, footer and content areas, along with css/js. Basically, the template system uses the URL to decide which template to parse, based on the file system path. URL: "site.com/foo/bar" will look in the template folder and use the document, content, header & footer. Then it looks in foo, if foo containes a doc, head, footer, or content it will override the previous one and use it. Each level can also include a css and js folder. This is useful so you can override styles based on the section of the site your in. I know it sounds a bit hacky, but its actually really efficient. Code: /templates You can pass variables, set custom areas, and override the templates at any point too. so for some code: We chose to call it "view" so that we don't confuse anybody internally who is used to working with views. Also, we still use CI views, but we use them as reusables for our modules. Those views then get passed into variables to use in the template. Code: //Load the lib Future: Pulling the JS/CSS minifying and even variable parsing/caching We will pull it out of our SVN soon and stick it on google code or something, but for now i'll just keep posting the zip files as we upgrade. 8 Minute Screencast http://vimeo.com/2170796 Download: http://www.page12.com/ci/viewlib/ViewLib.zip Default Demo templates http://www.page12.com/ci/viewlib/templates.zip |
Welcome Guest, Not a member yet? Register Sign In |