Run converters before running liquid on a file? #889

Closed
jyruzicka opened this Issue Mar 27, 2013 · 9 comments

Comments

Projects
None yet
6 participants

A relatively simple change - I figure this hasn't been done because of something I've missed, but I figured it wouldn't hurt to file an issue.

In convertible.rb, in the do_layout method (line 78 or so in 0.12.1):

begin
  self.content = Liquid::Template.parse(self.content).render!(payload, info)
rescue => e
  puts "Liquid Exception: #{e.message} in #{self.name}"
  e.backtrace.each do |backtrace|
    puts backtrace
  end
  abort("Build Failed")
end

self.transform

Is there any reason that liquid runs before converters do? I could see this being a problem, for example, if you have a haml file, and liquid spits out some html that doesn't conform to haml's whitespacing requirements.

Swapping the order of these (convert, then run liquid) would fix this problem (you always know that liquid will be run after your converter - you don't know what sort of converter will be run after you run liquid on the raw content). This would also allow you to put liquid tags into the html in your converter, and have them get run (which is the real reason I'm interested in switching them around).

Owner

parkr commented Mar 27, 2013

HAML isn't currently officially supported by Jekyll.

We will eventually switch them around:

  1. turn liquid statements into some special hash that no converter will process
  2. convert
  3. replace hashes with corresponding liquid statements
  4. parse liquid
  5. output

Is this waiting on some other feature, or is it open to enthusiastic individuals forking and trying it on their own branch?

Owner

mattr- commented Mar 27, 2013

I don't believe this is waiting on any other feature. Fork away!

  • 1 I think this is a great optional setting.
Owner

parkr commented May 23, 2013

I get worried about this, as it makes it more difficult for others to diagnose any problems you might be having if this happens first. Also {% ... %} and {{ ... }} aren't valid markdown, are they?

Not sure what the original rationale was, though, for this ordering.

This would for sure allow us to properly run SLIM or HAML before running liquid. It would solve indentation problems.

Owner

parkr commented May 23, 2013

Don't SLIM and HAML basically do exactly what Liquid does? Can you give me an example of how you write a HAML template for Jekyll?

Yep, you are right. It's actually a waste to convert the template twice.

Here is an example file: https://gist.github.com/hendricius/5640419

I was already looking for a solution to replace the {% %} tags. That would
allow us to go for the = tag SLIM uses. However, more problems are coming,
like how would you do a for loop etc? Anyone has a solution?

On Fri, May 24, 2013 at 1:48 AM, Parker Moore notifications@github.comwrote:

Don't SLIM and HAML basically do exactly what Liquid does? Can you give me
an example of how you write a HAML template for Jekyll?


Reply to this email directly or view it on GitHubhttps://github.com/mojombo/jekyll/issues/889#issuecomment-18378906
.

Member

penibelst commented May 12, 2014

@jekyll/owners: can be closed.

@parkr parkr closed this Jul 31, 2014

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.