Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Liquid markup in posts being stripped out completely #411

Closed
duckpuppy opened this Issue · 3 comments

3 participants

@duckpuppy

If I write a post with the following content:

---
title: test
layout: post
---
This is a test.
{{ post.date }}

and render it using jekyll, the resulting post will contain the text "This is a test.", but won't contain either the literal string {{ post.date }} or the correct value. It's like it's going through the parser, but evaluating to nothing. No Liquid tags are working in the actual post content, however I use {{ post.date }} (and several other Liquid tags) in the post layout and they are working fine.

@duckpuppy

Some experimenting with irb has narrowed the problem down to this bit of code in convertible.rb (line 78):

  begin
    self.content = Liquid::Template.parse(self.content).render(payload, info)
  rescue => e
    puts "Liquid Exception: #{e.message} in #{self.name}"
  end

After this runs, self.content is stripped of all the template tags. I assume that this step should have done the replacement, but for some reason the elements aren't available to be replaced, and so get replaced with nothing.

Also, it's only the post related tags that aren't working. The site and page tags work fine (including {{ page.content }}, which shows the unprocessed source for the page).

@envygeeks
Owner

I don't know the file layout you are using so I don't know exactly how you are going about doing what you are doing but here are a few tips that should help you: post.var becomes page.var when standalone and not inside of the {{ posts }} loop. So your page should be:

---
title: test
layout: post
---

This is a test
{{ page.date }}

The snippet of code you pointed to should output an error if there was one, for example if you do {{ this.that }} you will see an error but if I remember right there is a gotcha with posts and page because they do exist so if you try to tap something and it's not there you won't always see an error, I've experienced that a few times.

@parkr
Owner

It's a matter of using the proper reference. Try page instead of post.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.