Changeset 147
- Timestamp:
- 03/01/06 22:21:12 (3 years ago)
- Files:
-
- tags/0.3.3/pyramid/page.py (modified) (4 diffs)
- tags/0.3.3/sampledata/simple/index.html (modified) (1 diff)
- tags/0.3.3/sampledata/simple/index.yml (modified) (1 diff)
- tags/0.3.3/sampledata/simple/subdir/index.html (modified) (1 diff)
- tags/0.3.3/sampledata/simple/subdir/index.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tags/0.3.3/pyramid/page.py
r142 r147 1 import sys 1 2 from nevow import rend, stan, flat, compy as components, tags as T 2 3 from nevow.loaders import xmlstr … … 13 14 pgen['divider'] = str 14 15 return pgen 16 15 17 class FragmentError(Exception): 16 18 """Base class for fragment exceptions.""" … … 32 34 ''' wrap template fragments in data and namespace invisible tag 33 35 ''' 34 return '<n:invisible xmlns: n="http://nevow.com/ns/nevow/0.1" n:data="dict" n:render="mapping">%s</n:invisible>' % file(template).read()36 return '<n:invisible xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:n="http://nevow.com/ns/nevow/0.1" n:data="dict" n:render="mapping">%s</n:invisible>' % file(template).read() 35 37 36 38 def data_dict(self, ctx, data): … … 59 61 return '' 60 62 63 def render_slice(self,slice): 64 from nevow import tags 65 def render(self,context,data): 66 start,end = slice.split(':') 67 try: 68 if start.strip() == '': 69 start = 0 70 else: 71 start = int(start) 72 if end.strip() == '': 73 end = len(data) 74 else: 75 end = int(end) 76 except ValueError: 77 raise 'invalid slice values' 78 79 tag = context.tag 80 headers = tag.allPatterns('header') 81 pattern = tag.patternGenerator('item') 82 divider = tag.patternGenerator('divider', default=tags.invisible) 83 content = [(pattern(data=element), divider(data=element)) for element in data[int(start):int(end)]] 84 85 if not content: 86 content = tag.allPatterns('empty') 87 else: 88 ## No divider after the last thing. 89 content[-1] = content[-1][0] 90 footers = tag.allPatterns('footer') 91 92 return tag.clear()[ headers, content, footers ] 93 return render 94 95 61 96 def render_breadcrumb(self, ctx, data): 62 97 tag = ctx.tag tags/0.3.3/sampledata/simple/index.html
r1 r147 10 10 <li>c:<n:slot name="c">default value for c</n:slot></li> 11 11 </ul> 12 13 <ul n:render="slice 0:10" n:data="d"> 14 <li n:pattern="item" n:render="mapping"><n:slot name="item" /></li> 15 </ul> 12 16 </body> 13 17 </html> tags/0.3.3/sampledata/simple/index.yml
r1 r147 5 5 b: 2 / globals 6 6 c: 3 / globals 7 d: 8 - item: a 9 - item: b 10 - item: c 11 - item: d 12 - item: e 13 - item: f 14 - item: g 15 - item: h 7 16 local: 8 17 c: 3 / locals tags/0.3.3/sampledata/simple/subdir/index.html
r1 r147 9 9 <li>b:<n:slot name="b">default value for b</n:slot></li> 10 10 <li>c:<n:slot name="c">default value for c</n:slot></li> 11 <li>d:<n:slot name="d">default value for d</n:slot></li> 11 </ul> 12 13 <ul n:render="slice :-2" n:data="d"> 14 <li n:pattern="item" n:render="mapping"><n:slot name="item" /></li> 12 15 </ul> 13 16 </body> tags/0.3.3/sampledata/simple/subdir/index.yml
r1 r147 2 2 template: index.html 3 3 global: 4 c: 3 /subdir globals5 d: 4 /subdir globals4 a: 3 /subdir globals 5 b: 4 /subdir globals 6 6 local: 7 7 b: 2 /subdir locals
