rohit01
rohit01

Reputation: 227

How to declare newline character variable in Liquid template?

I want to do something like this:

{% assign newline = "\n" %}
newline = '{{xxxx}}'

But this returns the output as:

newline = '\n'

I expect output as:

newline = '  
'

Upvotes: 2

Views: 3193

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

I'm afraid you cannot use the "\n" which is a regular expression piece that cannot be parsed by regular Jekyll filters.

But you can find another way.

Compressing css

You can use native Jekyll sass converter.

  • Rename your _includes/css/styles.css to css/styles.scss

  • Add a front matter to it

    ---
    # this yaml front matter, even empty, forces Jekyll to parse sass or scss
    # you can put plain css in this file, it will simply benefit from
    # compression functionalities
    ---
    html,body,div,span ....
    
  • configure you sass behavior in _config.yml

    sass:
      # style : nested (default), compact, compressed, expanded
      #         :nested, :compact, :compressed, :expanded also works
      # see http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style
      # on a typical twitter bootstrap stats are :
      # nested 138,7kB, compact 129,1kB, expanded 135,9 kB, compressed 122,4 kB
      style: compressed
    

compressing html

You just can use the imathis html minification plugin.

You will then need to use a different workflow to publish your sources to Github pages.

You can find useful inspiration in Octopress Rakefile or in my works on versioning workflows for sites using plugins.

Upvotes: 2

Related Questions