title: jade (for nodejs) substrings in templates
body: <p>Would anyone please advise how in jade for nodejs I can truncate a string to a number of characters/words, ideally conscious about the HTML markup within the string?</p>
  
  <p>This should be similar to Django's truncatechars/truncatewords and truncatechars_html/truncatewords_html filters.</p>
  
  <p>If this doesn't exist in jade, which way is right to go? I'm starting my first nodejs+express+CouchDB app, and could do it within nodejs code but it seems that filters are much more appropriate.
  I would also consider writing a filter like this (and others) if I knew how :))</p>
  
  <p>Just a quick illustration:</p>
  
  <pre><code>// in nodejs:
  // body variable comes from CouchDB
  res.render('home.jade', { title : "test", featuredNews : eval(body)});
  
  // in home.jade template:
      ul.thumbnails
      each article in featuredNews.rows
          a(href="#"+article.slug)
              li.span4
                  div.value.thumbnail
                      img(align='left',src='http://example.com/image.png')
                      p!= article.value.description:truncatewords_html(30)
  </code></pre>
  
  <p>So I've made up the truncatewords_html(30) thing to illustrate what I think it should be similar to.</p>
  
  <p>Will appreciate any ideas!</p>
  
  <p>Thanks,
  Igor</p>