summaryrefslogtreecommitdiff
path: root/recipes/index.tmpl
blob: cd068b5f82bf7a642c2ec98a7ca7258309e84f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#import os
#From Cheetah.Template import Template
#from Cheetah.Filters import Markdown

#import WikiRoot
#extends WikiRoot.WikiRoot

#attr PathPrefix = '../'
#attr ExecuteContentPath = 'recipes/content/'
#attr HyperlinkContentPath = 'content/'

#def pagename()
    #return 'Recipes'
#end def

#def content()
#transform Markdown
Cheetah Recipes
===============

Here are the available recipes thus far:

#for dirpath, dirnames, filenames in $os.walk($ExecuteContentPath)
    #for file in filenames
        #if file.endswith('.markdown') and $generateRecipePage($file)
* [${file.replace('_', ' ').replace('.markdown', '')}](${HyperlinkContentPath}${file.replace('.markdown', '.html')})
        #end if
    #end for
#end for 


If you're really hungry for some Cheetah recipies, you can check out the 
out-of-date [Cheetah recipes page](http://wiki.cheetahtemplate.org/cheetah-recipes.html?) 
from the old Wiki
#end def

#def generateRecipePage(filepath)
    #set fd = $open('%s%s' % ($ExecuteContentPath, $filepath), 'r')
    #set content = $fd.readlines()
    #silent $fd.close()
    #set tmpl = Template('''
        #from Cheetah.Filters import Markdown
        #import WikiRoot
        #extends WikiRoot.WikiRoot
        #attr PathPrefix = '../../'
        #def pagename()
            #return $PageName
        #end def

        #def content
        #transform Markdown
            $recipe
        #end def
    ''', searchList=[{'PageName' : $filepath.replace('.markdown', ''), 'recipe' : ''.join($content)}])
    #set fd = open('%s%s' % ($ExecuteContentPath, $filepath.replace('.markdown', '.html')), 'w')
    #silent fd.write(unicode(tmpl).encode('utf-8'))
    #silent fd.close()
    #return True
#end def