Skip to content

Instantly share code, notes, and snippets.

@danmactough
Created September 28, 2011 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmactough/1249107 to your computer and use it in GitHub Desktop.
Save danmactough/1249107 to your computer and use it in GitHub Desktop.
Jade Issue #354
html
body
h1 My Site
p Welcome to my super lame site.
include template.jqtl
/**
* Module dependencies.
*/
var jade = require('jade')
, path = __dirname + '/includes.jade'
, str = require('fs').readFileSync(path, 'utf8')
, fn = jade.compile(str, { filename: path, pretty: true });
console.log(fn());
<script id="template" type="text/x-jquery-tmpl">
<div class="info">
<a id="display" href="#">Switch to compact view</a></li>
<p class="updated">Updated <time datetime="${dateFormat(metadata.whenGMT, 'isoUtcDateTime')}">${dateFormat(metadata.whenGMT, 'timeDate')}</time></p>
</div>
{{each(f,feed) updatedFeeds.updatedFeed}}
<div class="section">
<div class="header">
<h2>
{{if feed.websiteUrl}}<a href="${feed.websiteUrl}">{{/if}}<img class="icon" src="${getFavicon(feed.websiteUrl)}" alt="">{{if feed.websiteUrl}}</a>{{/if}}
{{if feed.websiteUrl}}<a href="${feed.websiteUrl}">{{/if}}${feed.feedTitle}{{if feed.websiteUrl}}</a>{{/if}}
(<a href="${feed.feedUrl}" title="Subscribe to ${feed.feedTitle}">Feed</a>)
</h2>
<span class="time">${dateFormat(feed.whenLastUpdate, 'timeDate')}</span>
</div>
{{each(i,item) feed.item}}
<div class="article">
<div class="header">
<h3><a href="{{if item.permaLink}}${item.permaLink}{{else}}${item.link}{{/if}}" rel="external">{{if item.title}}${item.title}{{else}}${item.body}{{/if}}</a></h3>
</div>
{{if item.title}}
{{if item.body}}
<div class="description">
{{each(t,thumbnail) item.thumbnail}}
<img class="thumbnail" src="${thumbnail.url}" width="${thumbnail.width}" height="${thumbnail.height}" alt="">
{{/each}}
${getText(item.body)}
</div>
{{/if}}
{{/if}}
<div class="footer">
<span class="time">${timeDifference(item.pubDate)}</span>
<ul class="actions">
{{if item.comments}}
<li><a href="${item.comments}" rel="external nofollow" target="_blank">Comment</a></li>
{{/if}}
{{each(e,enclosure) item.enclosure}}
<li class="enclosure ${getEnclosureType(enclosure.type)}"><a href="${enclosure.url}">Download enclosure (${enclosure.type}, ${getEnclosureSize(enclosure.length)})</a></li>
{{/each}}
</ul>
</div>
</div>
{{/each}}
</div>
{{/each}}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment