Skip to content

Conversation

@giniedp
Copy link

@giniedp giniedp commented Nov 14, 2014

The current implementation does not support else for for and if tags and case for when.
We could try to add special cases but liquid allows registration of custom blocks that could allow even other branches.
However we can not predict all possible cases.
With this fix an if condition would be written as follows

  % if page.author
    | {{ page.author }}
  % else
    | anonymous
  % endif

As you can see we now have to write endif explicitly but this cant be avoided because of the reasons above.

@minad
Copy link
Member

minad commented Nov 14, 2014

Ok, makes sense. However you could add a special filter which checks for missing end liquid tags. Slim does the same: https://github.com/slim-template/slim/blob/master/lib/slim/end_inserter.rb

@mrcljx
Copy link

mrcljx commented Nov 14, 2014

The EndInserter relies on a closed set of keywords (see IF_RE and ELSE_RE). The "problem" with Liquid is that this could be anything, since it allows registration of custom tags (i.e. "custom keywords")

I've been thinking about building an inline JSBin alternative as a liquid tag. And it has "css", "coffee" and other else-branches. Sliq doesn't work with it though (but would with this PR applied).

h2 Just an inline JSBin alternative

% example
  div 
    a href="Ping"
% sass
  plain:
    a
      color: red
% coffee
  plain:
    $ ->
      $("a").click ->
        alert "Pong"
% endexample

Thinking even further a block could also end with a different tag than it opened with (I admit that this is a quite esoteric case).

@minad
Copy link
Member

minad commented Nov 14, 2014

Lets just assume that the closing tag is the same. Then it is pretty easy to implement the end inserter. The only cases that have to be handled specially are if/else etc.

@mrcljx
Copy link

mrcljx commented Nov 14, 2014

But how can you know that I have implemented an "else" that is called "coffee" beforehand?

@minad
Copy link
Member

minad commented Nov 14, 2014

This you should not do maybe. I don't know how liquid works exactly and what is allowed.

Btw. this project and jekyll-slim are unmaintained since I am not using them.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants