Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

white space control in jekyll - why does {%- ... -%} a la liquid not work?

Tags:

jekyll

liquid

The liquid documentation states that

By including hyphens in your assign tag, you can strip the generated whitespace from the rendered template ... if you don't want any of your tags to output whitespace, as a general rule you can add hyphens to both sides of all your tags ({%- and -%}):

When I try in jekyll

{%- case key -%}

I get the error

Error: Liquid syntax error (line 139): Tag '{%- case key -%}' was not
properly terminated with regexp: /\%\}/

There are many posts about excessive whitespace in the jekyll generated html, for example Compressing Liquid generated code.

They all complain about dilute HTML output and discuss plug-ins as solution. My simple questions are:

  1. Why does {%- ... -%} not work in jekyll ?
  2. Why behaves jekyll differently than the liquid documentation suggests
like image 943
wfjm Avatar asked Nov 06 '16 15:11

wfjm


1 Answers

Jekyll < v3.5.0 use liquid v3.0.6. White space control is only available in liquid v4 and this version will soon land in Jekyll.

As of 18 June 2017, Jekyll v3.5.0 has upgraded to Liquid v4. {%- ... -%} now works.

like image 60
David Jacquel Avatar answered Sep 21 '22 16:09

David Jacquel