So this is an html partial template from my theme:
{{ "<!-- Portfolio Grid Section -->" | safeHTML }}
<section id="news" class="bg-light-gray">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading">{{ with .Site.Params.news.title }}{{ . | markdownify }}{{ end }}</h2>
<h3 class="section-subheading text-muted">{{ with .Site.Params.news.subtitle }}{{ . | markdownify }}{{ end }}</h3>
</div>
</div>
<div class="row">
{{ range .Site.Data.news }}
<div class="col-md-4 col-sm-6 portfolio-item">
<div class="portfolio-caption">
<h4>{{ .title | markdownify }}</h4>
</div>
<a href="#newsModal{{ .modalID }}" class="portfolio-link" data-toggle="modal">
<div class="portfolio-hover">
<div class="portfolio-hover-content">
<i class="fa fa-plus fa-3x"></i>
</div>
</div>
{{ $url := printf "img/news/%s" .preview }}
<img src="{{ $url | absURL }}" class="img-responsive" alt="">
</a>
</div>
{{ end }}
</div>
</div>
</section>
What I want to do is only have it show the 4 latest news items on the page.
However, if I do, for example {{ range last 4 .Site.Data.news }}
I get ERROR: 2017/01/17 15:15:31 general.go:236: theme/partials/news.html is an incomplete or empty template
Any ideas what I’m doing wrong?