Skip to content

Instantly share code, notes, and snippets.

@richleland
Created May 2, 2012 15:07
Show Gist options
  • Save richleland/2577294 to your computer and use it in GitHub Desktop.
Save richleland/2577294 to your computer and use it in GitHub Desktop.
def format_sidebar(self, node):
"""
Formast the Sidebar type for web clients.
"""
payload = node['payload']
node['formatted'] = {}
for key, value in payload.items():
item_list = []
for item in value:
output = item['text']
if 'style' in item:
for style in item['style']:
output = self.wrap(output, style.lower())
if 'href' in item:
output = self.wrap(output, 'a', {'href': item['href']})
item_list.append(output)
node['formatted'][key] = ''.join(item_list)
return node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment