diff options
author | R. Tyler Ballance <tyler@slide.com> | 2009-05-30 12:06:23 -0700 |
---|---|---|
committer | R. Tyler Ballance <tyler@slide.com> | 2009-05-30 12:06:23 -0700 |
commit | 77afcbb4b482cc9b0af27d19257237f2d7d088b8 (patch) | |
tree | 47efee8ac5af87e0f04c95c3307c3e160f5a7c38 | |
parent | 44c63c1805cbb6537132808191207f9ec704b79e (diff) | |
download | python-cheetah-77afcbb4b482cc9b0af27d19257237f2d7d088b8.tar.gz |
Add a bit more onto the Inheritance recipe, added 'last edited' timestamp
Signed-off-by: R. Tyler Ballance <tyler@slide.com>
-rw-r--r-- | recipes/content/Basic_Inheritance.html | 17 | ||||
-rw-r--r-- | recipes/content/Basic_Inheritance.markdown | 20 | ||||
-rw-r--r-- | recipes/content/Precompiled_Templates.html | 1 | ||||
-rw-r--r-- | recipes/content/Writing_A_Recipe.html | 1 | ||||
-rw-r--r-- | recipes/index.tmpl | 7 |
5 files changed, 43 insertions, 3 deletions
diff --git a/recipes/content/Basic_Inheritance.html b/recipes/content/Basic_Inheritance.html index 5ba8c78..213263c 100644 --- a/recipes/content/Basic_Inheritance.html +++ b/recipes/content/Basic_Inheritance.html @@ -376,7 +376,9 @@ Python.</p> <h2>Cheetah inheriting from Python</h2> <p>Whether or not you are aware of it, Cheetah templates are always inheriting from a Python class by default. Unless otherwise denoted, Cheetah templates are compiled -to Python classes that subclass from the Cheetah.Template.Template class.</p> +to Python classes that subclass from the <code>Cheetah.Template.Template</code> class.</p> +<p>What if you would like to introduce your own Template base class? Easily acheived by +defining your own Template class in a Python module, for example:</p> <pre><code>import Cheetah.Template class CookbookTemplate(Cheetah.Template.Template): @@ -385,6 +387,19 @@ class CookbookTemplate(Cheetah.Template.Template): def pageName(self): return self._page or 'Unknown' </code></pre> +<p><strong>Figure 1. cookbook.py</strong></p> +<p>For this example, I want all my subclasses of the <code>CookbookTemplate</code> to define a +page author which will be used in some shared rendering code, to accomplish this +my templates will need to subclass from <code>CookbookTemplate</code> explicitly instead of +implicitly subclassing from <code>Cheetah.Template.Template</code></p> +<pre><code>#import cookbook +#extends cookbook.CookbookTemplate +#attr author = 'Tavis Rudd' + +## The rest of my recipe template would be below +</code></pre> +<p><strong>Figure 2. recipe1.tmpl</strong></p> +<p><span style="float: right; clear: both;"><em>Last edited: Sat May 30 12:05:40 2009 </em></span></p> </div> <div id="rightcontent"> diff --git a/recipes/content/Basic_Inheritance.markdown b/recipes/content/Basic_Inheritance.markdown index 2aa5de3..19eaac0 100644 --- a/recipes/content/Basic_Inheritance.markdown +++ b/recipes/content/Basic_Inheritance.markdown @@ -31,7 +31,10 @@ Cheetah inheriting from Python ------------------------------ Whether or not you are aware of it, Cheetah templates are always inheriting from a Python class by default. Unless otherwise denoted, Cheetah templates are compiled -to Python classes that subclass from the Cheetah.Template.Template class. +to Python classes that subclass from the `Cheetah.Template.Template` class. + +What if you would like to introduce your own Template base class? Easily acheived by +defining your own Template class in a Python module, for example: import Cheetah.Template @@ -40,3 +43,18 @@ to Python classes that subclass from the Cheetah.Template.Template class. author = 'R. Tyler Ballance' def pageName(self): return self._page or 'Unknown' +**Figure 1. cookbook.py** + +For this example, I want all my subclasses of the `CookbookTemplate` to define a +page author which will be used in some shared rendering code, to accomplish this +my templates will need to subclass from `CookbookTemplate` explicitly instead of +implicitly subclassing from `Cheetah.Template.Template` + + \#import cookbook + \#extends cookbook.CookbookTemplate + \#attr author = 'Tavis Rudd' + + \#\# The rest of my recipe template would be below +**Figure 2. recipe1.tmpl** + + diff --git a/recipes/content/Precompiled_Templates.html b/recipes/content/Precompiled_Templates.html index cbd8885..5e2c213 100644 --- a/recipes/content/Precompiled_Templates.html +++ b/recipes/content/Precompiled_Templates.html @@ -396,6 +396,7 @@ method" for executing the Cheetah template. You can adjust the example above in results = getattr(tmpl, mainMethod)() </code></pre> <p><strong>Figure 3. Dynamic runner.py</strong></p> +<p><span style="float: right; clear: both;"><em>Last edited: Sat May 30 12:05:40 2009 </em></span></p> </div> <div id="rightcontent"> diff --git a/recipes/content/Writing_A_Recipe.html b/recipes/content/Writing_A_Recipe.html index b8edcda..ca30611 100644 --- a/recipes/content/Writing_A_Recipe.html +++ b/recipes/content/Writing_A_Recipe.html @@ -353,6 +353,7 @@ border:dashed 1px #888; padding:6px; font-size:1.1em; color:#fff;} <div id="centercontent"> <h1>Writing a "Recipe"</h1> <p>I'll fill this out soon enough :)</p> +<p><span style="float: right; clear: both;"><em>Last edited: Sat May 30 12:05:40 2009 </em></span></p> </div> <div id="rightcontent"> diff --git a/recipes/index.tmpl b/recipes/index.tmpl index da79f99..c1808b6 100644 --- a/recipes/index.tmpl +++ b/recipes/index.tmpl @@ -4,6 +4,7 @@ useLegacyImportMode=False #end compiler-settings #import os +#import time #From Cheetah.Template import Template #from Cheetah.Filters import Markdown @@ -57,9 +58,13 @@ from the old Wiki #def content #transform Markdown %s + + + +<span style="float: right; clear: both;">*Last edited: $Edited *</span> #end def ''' % (''.join(content)), - searchList=[{'PageName' : filepath.replace('.markdown', '')}]) + searchList=[{'Edited' : time.ctime(), 'PageName' : filepath.replace('.markdown', '')}]) ## Write the results of the template's execution to a .html file #set fd = open('%s%s' % ($ExecuteContentPath, filepath.replace('.markdown', '.html')), 'w') |