Rhys ! avatar Rhys ! committed a6ace25 Merge

merged tempita

Comments (0)

Files changed (8)

         template.user = self.user
         template.client_ie = self.client_is_ie
         
-        return unicode(template)
+        return template.substitute_attrs()
 
     def render(self, template, type='application/xhtml+xml', cache=True, code=200):
         if type == 'application/xhtml+xml' and self.client_is_ie:

templates/create.tmpl

-#from templates.wrapper import wrapper
-#extends wrapper
-#def title: New post
-#def content
-#filter None
+{{inherit "wrapper.tmpl"}}
+{{def title}}New post{{enddef}}
             <header>
                 <h1>New post</h1>
             </header>
             <div>
-#if $error
+{{if error}}
                 <p id="error">
-    #if $error == 'empty'
+    {{if error == 'empty'}}
                     <span>Cannot have empty topic or content.</span>
-    #end if
+   {{endif}}
                 </p>
-#end if
+{{endif}}
                 <form method="post" action="/create">
                     <p><strong>Topic</strong>: <input type="text" name="topic" /></p>
                     <p><textarea name="content" /></p>
                     <p><input type="submit" value="Post" /></p>
                 </form>
             </div>
-#end filter
-#end def

templates/home.tmpl

-#from templates.wrapper import wrapper
-#extends wrapper
-#def title: Welcome
-#def content
-#filter None
+{{inherit "wrapper.tmpl"}}
+{{def title}}Welcome{{enddef}}
             <header>
                 <h1>Welcome</h1>
             </header>
                 <p>This project was created to provide a simple example of the use of <a href="http://bitbucket.org/rimmington/rgframe">rgframe</a> and <a href="http://code.google.com/appengine/">Google App Engine's</a> BigTable database.</p>
                 <p>The code is available under the GPLv3 license; grab it from <a href="http://bitbucket.org/rimmington/rgframe-example">Bitbucket</a>.</p>
             </div>
-#end filter
-#end def

templates/list.tmpl

-#from templates.wrapper import wrapper
-#extends wrapper
-#def title: $of
-#def content
-#filter None
+{{inherit "wrapper.tmpl"}}
+{{def title}}{{of}}{{enddef}}
             <header>
-                <h1>$of</h1>
+                <h1>{{of}}</h1>
             </header>
-#for post in $query
+{{for post in query}}
             <div class="post">
-                <p><a href="/author/$post.author.key().id_or_name()"><cite>$post.author.name</cite></a> <a href="/post/$post.key().id_or_name()">posted</a> about <a href="/topic/$post.topic"><span class="topic">$post.topic</span></a>:</p>
+                <p><a href="/author/{{post.author.key().id_or_name() | url}}"><cite>{{post.author.name}}</cite></a> <a href="/post/{{post.key().id_or_name() | url}}">posted</a> about <a href="/topic/{{post.topic | url}}"><span class="topic">{{post.topic}}</span></a>:</p>
                 <blockquote>
-                    <pre>$post.content</pre>
+                    <pre>{{post.content}}</pre>
                 </blockquote>
             </div>
-#end for
-#end filter
-#end def
+{{endfor}}

templates/not_found.tmpl

-#from templates.wrapper import wrapper
-#extends wrapper
-#def title: 404
-#def content
-#filter None
+{{inherit "wrapper.tmpl"}}
+{{def title}}404{{enddef}}
             <header>
                 <h1>404 Not Found</h1>
             </header>
             <div>
                 <p>Whatever you were looking for, it ain't here.</p>
             </div>
-#end filter
-#end def

templates/view_post.tmpl

-#from templates.wrapper import wrapper
-#extends wrapper
-#def title: Single post
-#def content
-#filter None
+{{inherit "wrapper.tmpl"}}
+{{def title}}Single post{{enddef}}
             <header>
                 <h1>Single post</h1>
             </header>
             <div class="post">
-                <p><a href="/author/$post.author.key().id_or_name()"><cite>$post.author.name</cite></a> posted about <a href="/topic/$post.topic"><span class="topic">$post.topic</span></a>:</p>
+                <p><a href="/author/{{post.author.key().id_or_name() | url}}"><cite>{{post.author.name}}</cite></a> posted about <a href="/topic/{{post.topic | url}}"><span class="topic">{{post.topic}}</span></a>:</p>
                 <blockquote>
-                    <pre>$post.content</pre>
+                    <pre>{{post.content}}</pre>
                 </blockquote>
             </div>
-#end filter
-#end def

templates/wrapper.py

-#!/usr/bin/env python
-
-
-
-
-##################################################
-## DEPENDENCIES
-import sys
-import os
-import os.path
-from os.path import getmtime, exists
-import time
-import types
-import __builtin__
-from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
-from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
-from Cheetah.Template import Template
-from Cheetah.DummyTransaction import DummyTransaction
-from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
-from Cheetah.CacheRegion import CacheRegion
-import Cheetah.Filters as Filters
-import Cheetah.ErrorCatchers as ErrorCatchers
-
-##################################################
-## MODULE CONSTANTS
-try:
-    True, False
-except NameError:
-    True, False = (1==1), (1==0)
-VFFSL=valueFromFrameOrSearchList
-VFSL=valueFromSearchList
-VFN=valueForName
-currentTime=time.time
-__CHEETAH_version__ = '2.0.1'
-__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
-__CHEETAH_genTime__ = 1288417680.5777709
-__CHEETAH_genTimestamp__ = 'Sat Oct 30 16:48:00 2010'
-__CHEETAH_src__ = 'wrapper.tmpl'
-__CHEETAH_srcLastModified__ = 'Sat Oct 30 16:47:34 2010'
-__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
-
-if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
-    raise AssertionError(
-      'This template was compiled with Cheetah version'
-      ' %s. Templates compiled before version %s must be recompiled.'%(
-         __CHEETAH_version__, RequiredCheetahVersion))
-
-##################################################
-## CLASSES
-
-class wrapper(Template):
-
-    ##################################################
-    ## CHEETAH GENERATED METHODS
-
-
-    def __init__(self, *args, **KWs):
-
-        Template.__init__(self, *args, **KWs)
-        if not self._CHEETAH__instanceInitialized:
-            cheetahKWArgs = {}
-            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
-            for k,v in KWs.items():
-                if k in allowedKWs: cheetahKWArgs[k] = v
-            self._initCheetahInstance(**cheetahKWArgs)
-        
-
-    def e_title(self, **KWS):
-
-
-
-        ## Generated from #def $e_title: #filter Filter#$title#end filter at line 1, col 1.
-        trans = KWS.get("trans")
-        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
-            trans = self.transaction # is None unless self.awake() was called
-        if not trans:
-            trans = DummyTransaction()
-            _dummyTrans = True
-        else: _dummyTrans = False
-        write = trans.response().write
-        SL = self._CHEETAH__searchList
-        _filter = self._CHEETAH__currentFilter
-        
-        ########################################
-        ## START - generated method body
-        
-        _orig_filter_68840328 = _filter
-        filterName = 'Filter'
-        if self._CHEETAH__filters.has_key("Filter"):
-            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
-        else:
-            _filter = self._CHEETAH__currentFilter = \
-			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
-        _v = VFFSL(SL,"title",True) # '$title' on line 1, col 31
-        if _v is not None: write(_filter(_v, rawExpr='$title')) # from line 1, col 31.
-        _filter = self._CHEETAH__currentFilter = _orig_filter_68840328
-        
-        ########################################
-        ## END - generated method body
-        
-        return _dummyTrans and trans.response().getvalue() or ""
-        
-
-    def u(self, s, **KWS):
-
-
-
-        ## Generated from #def u($s): #filter UrlSafe#$s#end filter at line 2, col 1.
-        trans = KWS.get("trans")
-        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
-            trans = self.transaction # is None unless self.awake() was called
-        if not trans:
-            trans = DummyTransaction()
-            _dummyTrans = True
-        else: _dummyTrans = False
-        write = trans.response().write
-        SL = self._CHEETAH__searchList
-        _filter = self._CHEETAH__currentFilter
-        
-        ########################################
-        ## START - generated method body
-        
-        _orig_filter_76953061 = _filter
-        filterName = 'UrlSafe'
-        if self._CHEETAH__filters.has_key("UrlSafe"):
-            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
-        else:
-            _filter = self._CHEETAH__currentFilter = \
-			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
-        _v = VFFSL(SL,"s",True) # '$s' on line 2, col 29
-        if _v is not None: write(_filter(_v, rawExpr='$s')) # from line 2, col 29.
-        _filter = self._CHEETAH__currentFilter = _orig_filter_76953061
-        
-        ########################################
-        ## END - generated method body
-        
-        return _dummyTrans and trans.response().getvalue() or ""
-        
-
-    def respond(self, trans=None):
-
-
-
-        ## CHEETAH: main method generated for this template
-        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
-            trans = self.transaction # is None unless self.awake() was called
-        if not trans:
-            trans = DummyTransaction()
-            _dummyTrans = True
-        else: _dummyTrans = False
-        write = trans.response().write
-        SL = self._CHEETAH__searchList
-        _filter = self._CHEETAH__currentFilter
-        
-        ########################################
-        ## START - generated method body
-        
-        if VFFSL(SL,"client_ie",True): # generated from line 3, col 1
-            write('''<!DOCTYPE html>
-<html lang="en">
-''')
-        else: # generated from line 6, col 1
-            write('''<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-''')
-        write('''
-    <head>
-        <title>postr // ''')
-        _v = VFFSL(SL,"e_title",True) # '$e_title' on line 13, col 25
-        if _v is not None: write(_filter(_v, rawExpr='$e_title')) # from line 13, col 25.
-        write('''</title>
-        <meta charset="utf-8" />
-        <link rel="stylesheet"''')
-        if VFFSL(SL,"client_ie",True): # generated from line 15, col 31
-            write(''' type="text/css"''')
-        write(''' href="/site.css" />
-''')
-        if VFFSL(SL,"client_ie",True): # generated from line 16, col 1
-            write('''        <!--[if lt IE 9]>
-            <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
-        <![endif]-->
-''')
-        write('''    </head>
-
-    <body>
-    <div id="container">
-    \t<header>
-            <h1><a href="/">postr</a></h1>
-            <nav>
-''')
-        if VFFSL(SL,"user.logged_in",True): # generated from line 28, col 1
-            write('''                Salutations, <a href="''')
-            _v = VFFSL(SL,"user.uri",True) # '$user.uri' on line 29, col 39
-            if _v is not None: write(_filter(_v, rawExpr='$user.uri')) # from line 29, col 39.
-            write('''">''')
-            _v = VFFSL(SL,"user.name",True) # '$user.name' on line 29, col 50
-            if _v is not None: write(_filter(_v, rawExpr='$user.name')) # from line 29, col 50.
-            write('''</a>.<br />
-                <a href="''')
-            _v = VFFSL(SL,"user.logout_uri",True) # '$user.logout_uri' on line 30, col 26
-            if _v is not None: write(_filter(_v, rawExpr='$user.logout_uri')) # from line 30, col 26.
-            write('''">Logout</a>
-''')
-        else: # generated from line 31, col 1
-            write('''                <br />
-                <a href="''')
-            _v = VFFSL(SL,"user.login_uri",True) # '$user.login_uri' on line 33, col 26
-            if _v is not None: write(_filter(_v, rawExpr='$user.login_uri')) # from line 33, col 26.
-            write('''">Login</a>
-''')
-        write('''            </nav>
-            <hr class="clear" />
-            <nav id="bar">
-                <a href="/recent">Recent posts</a> |
-                <a href="/create">New post</a>
-            </nav>
-        </header>
-        <article id="main">
-''')
-        _orig_filter_13891071 = _filter
-        filterName = 'Filter'
-        if self._CHEETAH__filters.has_key("Filter"):
-            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
-        else:
-            _filter = self._CHEETAH__currentFilter = \
-			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
-        _v = VFFSL(SL,"content",True) # '$content' on line 44, col 1
-        if _v is not None: write(_filter(_v, rawExpr='$content')) # from line 44, col 1.
-        write(''' ''')
-        _filter = self._CHEETAH__currentFilter = _orig_filter_13891071
-        write('''        </article>
-        <footer>
-            &#169; Rhys ! 2010. Copyrights to posts and comments are held by their owners.
-        </footer>
-    </div>
-    </body>
-
-</html>
-''')
-        
-        ########################################
-        ## END - generated method body
-        
-        return _dummyTrans and trans.response().getvalue() or ""
-        
-    ##################################################
-    ## CHEETAH GENERATED ATTRIBUTES
-
-
-    _CHEETAH__instanceInitialized = False
-
-    _CHEETAH_version = __CHEETAH_version__
-
-    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
-
-    _CHEETAH_genTime = __CHEETAH_genTime__
-
-    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
-
-    _CHEETAH_src = __CHEETAH_src__
-
-    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
-
-    _mainCheetahMethod_for_wrapper= 'respond'
-
-## END CLASS DEFINITION
-
-if not hasattr(wrapper, '_initCheetahAttributes'):
-    templateAPIClass = getattr(wrapper, '_CHEETAH_templateClass', Template)
-    templateAPIClass._addCheetahPlumbingCodeToClass(wrapper)
-
-
-# CHEETAH was developed by Tavis Rudd and Mike Orr
-# with code, advice and input from many other volunteers.
-# For more information visit http://www.CheetahTemplate.org/
-
-##################################################
-## if run from command line:
-if __name__ == '__main__':
-    from Cheetah.TemplateCmdLineIface import CmdLineIface
-    CmdLineIface(templateObj=wrapper()).run()
-
-

templates/wrapper.tmpl

-#def $e_title: #filter Filter#$title#end filter
-#def u($s): #filter UrlSafe#$s#end filter
-#if $client_ie
+{{if client_ie}}
 <!DOCTYPE html>
 <html lang="en">
-#else
+{{else}}
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-#end if
+{{endif}}
 
     <head>
-        <title>postr // $e_title</title>
+        <title>postr // {{title | html}}</title>
         <meta charset="utf-8" />
-        <link rel="stylesheet"#if $client_ie# type="text/css"#end if# href="/site.css" />
-#if $client_ie
+        <link rel="stylesheet"{{if client_ie}} type="text/css"{{endif}} href="/site.css" />
+{{if client_ie}}
         <!--[if lt IE 9]>
             <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
         <![endif]-->
-#end if
+{{endif}}
     </head>
 
     <body>
     	<header>
             <h1><a href="/">postr</a></h1>
             <nav>
-#if $user.logged_in
-                Salutations, <a href="$user.uri">$user.name</a>.<br />
-                <a href="$user.logout_uri">Logout</a>
-#else
+{{if user.logged_in}}
+                Salutations, <a href="{{user.uri}}">{{user.name}}</a>.<br />
+                <a href="{{user.logout_uri}}">Logout</a>
+{{else}}
                 <br />
-                <a href="$user.login_uri">Login</a>
-#end if
+                <a href="{{user.login_uri}}">Login</a>
+{{endif}}
             </nav>
             <hr class="clear" />
             <nav id="bar">
             </nav>
         </header>
         <article id="main">
-#filter Filter
-$content #slurp
-#end filter
+{{self.body.strip() | html}}
         </article>
         <footer>
-            &#169; Rhys ! 2010. Copyrights to posts and comments are held by their owners.
+            &#169; Rhys ! 2011. Copyrights to posts and comments are held by their owners.
         </footer>
     </div>
     </body>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.