metalsmith / excerpts

A Metalsmith plugin to extract an excerpt from HTML files.
MIT License
24 stars 26 forks source link

Excerpt html does not get interpreted #9

Closed fschrofner closed 10 years ago

fschrofner commented 10 years ago

I guess it's my bad, but I'm nevertheless posting it here as I don't know what to do anymore.
I'm trying to implement my blog using excerpts and therefore I'm iterating over all my posts like this:

{{#each collections.blog}}
  <h3><a href="/{{ this.path }}">{{ this.title }}</a></h3>
  <p class="meta">{{formatDate this.date 'Do MMM YYYY'}}</p>
  {{ this.excerpt }}
{{/each}}

The result I'm getting looks something like this:

screenshot - 2014-08-19 - 22 10 50

So the html somehow does not get interpreted. When I view one of the blogposts on its own, the html is correct. Would you maybe guide me into the right direction?

The source code of my metalsmith script can be found here: https://bitbucket.org/FlorianSchrofner/flosch.at/src

KyleKing commented 10 years ago

Using handlebars, you can remove ("escape") the html. Try: {{{ this.excerpt }}}

Like this:

{{#each collections.blog}}
  <h3><a href="/{{ this.path }}">{{ this.title }}</a></h3>
  <p class="meta">{{formatDate this.date 'Do MMM YYYY'}}</p>
  {{{ this.excerpt }}}
{{/each}}

Source: http://handlebarsjs.com/ (Scroll down to HTML Escaping or search "{{{")

fschrofner commented 10 years ago

Thank you! Adding the additional curly brackets fixed the issue.