liquid

Order an array with Jekyll / liquid template

那年仲夏 提交于 2019-12-01 15:54:14
I'm trying to do the following. I use Jekyll to create a list of posts, and ordertem by category (monday...sunday) I'd like to have them displayed in chronological order but Jekyll order them alphabetically. Is it possible to sort an arry with Jekyll? I have added an order key to the post yaml to mirror monday = 1 ... sunday = 7 I'm trying to then sort the array with this order key, bu it doesn't work. {% for post in posts_collate %} {% capture class %} {{ post.tags | first }} {% endcapture%} {% capture club %} {{ post.tags | last }} {% endcapture%} {% if forloop.first %} <h2>our events</h2>

Order an array with Jekyll / liquid template

核能气质少年 提交于 2019-12-01 14:59:10
问题 I'm trying to do the following. I use Jekyll to create a list of posts, and ordertem by category (monday...sunday) I'd like to have them displayed in chronological order but Jekyll order them alphabetically. Is it possible to sort an arry with Jekyll? I have added an order key to the post yaml to mirror monday = 1 ... sunday = 7 I'm trying to then sort the array with this order key, bu it doesn't work. {% for post in posts_collate %} {% capture class %} {{ post.tags | first }} {% endcapture%}

Liquid and Arithmetic

寵の児 提交于 2019-12-01 06:07:35
I am working on some pagination and I am wondering if there is a way to tell liquid to only show 5 pages. The output I am looking for is << First 5 6 7 8 9 Last >> The logic I currently have in place works but it is showing all 30 some pages. {% for count in (2..paginator.total_pages) %} {% if count == paginator.page %} <span class="current">{{ count }}</span> {% else %} <a href="/page/{{ count }}/" class="pagenavi-page" title="{{ count }}">{{ count }}</a> {% endif %} {% endfor %} I would like to be able to make the 2 and paginator.total_pages be dynamic, I have tried {% for count in (

Shopify liquid: How can I conditionally include snippets in Shopify liquid?

浪尽此生 提交于 2019-12-01 03:38:46
I would like to include a snippet in a template but only if the snippet file exist. Is there any way I can do it? Now I'm just using: {% include 'snippetName' %} But this throws the error: Liquid error: Could not find asset snippets/snippetName.liquid The reason I need such a functionality is because I have a background process that adds the snippet later on. Had this problem myself. This was my solution: {% capture the_snippet_content %}{% include the_snippet %}{% endcapture %} {% unless the_snippet_content contains "Liquid error" %} {% include reviews_snippet %} {% endunless %} Basically

How to sort a hash converted to an array in Liquid

寵の児 提交于 2019-12-01 03:11:18
My understanding is that Liquid converts Ruby Hashes to arrays for use in tags. For example, when using Jekyll: {% for category in site.categories %} <li>{{ category[0] }}</li> {% endfor %} ... converts site.categories to an array of tuples in which [0] refers to the key, [1] the list of values. If I wanted the above category map to be sorted alphabetically by the key ([0] of each tuple) how can I do this? Neither the default Liquid implementation nor the additions made by Jekyll allow for what you want. I'm afraid what you want is simply not possible with the current setup. You would have to

Shopify liquid: How can I conditionally include snippets in Shopify liquid?

戏子无情 提交于 2019-11-30 23:56:07
问题 I would like to include a snippet in a template but only if the snippet file exist. Is there any way I can do it? Now I'm just using: {% include 'snippetName' %} But this throws the error: Liquid error: Could not find asset snippets/snippetName.liquid The reason I need such a functionality is because I have a background process that adds the snippet later on. 回答1: Had this problem myself. This was my solution: {% capture the_snippet_content %}{% include the_snippet %}{% endcapture %} {%

How to sort a hash converted to an array in Liquid

本小妞迷上赌 提交于 2019-11-30 23:13:11
问题 My understanding is that Liquid converts Ruby Hashes to arrays for use in tags. For example, when using Jekyll: {% for category in site.categories %} <li>{{ category[0] }}</li> {% endfor %} ... converts site.categories to an array of tuples in which [0] refers to the key, [1] the list of values. If I wanted the above category map to be sorted alphabetically by the key ([0] of each tuple) how can I do this? 回答1: Neither the default Liquid implementation nor the additions made by Jekyll allow

Is there a way to check whether a jekyll site is being served locally?

自闭症网瘾萝莉.ら 提交于 2019-11-30 22:57:36
I'd like to add the following line to my head.html solely when running jekyll serve locally: <script src="http://127.0.0.1:35729/livereload.js?snipver=1"></script> I'm thinking of using some simple liquid check if possible. Alternative solution (for example, if you're hosting your Jekyll site on your own server and not on GitHub Pages) : You can set a value in the config file _config.yml like this: environment: prod Then, you can have another config file which overrides the same value, I'll call it config_dev.yml : environment: dev When you just call jekyll build , it will use the value prod

How can I put a Liquid tag highlight in an ordered list?

荒凉一梦 提交于 2019-11-30 20:25:40
问题 This is what I want the page to be: <ol> <li>first</li> <li>second <code></code> </li> <li>third</li> </ol> This is what I'm writing: 1. first 2. second {% highlight ruby %} code here {% endhighlight %} 3. third And this is how it renders: <ol> <li>first</li> <li>second</li> </ol> <div class="highlight> code here </div> <ol> <li>third</li> </ol> So how do I write and it will render as what I want it to be? 回答1: I haven't been able to figure out how to use the "Pygments" highlighting for code

Variable within liquid if statement when calling shopify settings

大城市里の小女人 提交于 2019-11-30 17:31:05
问题 I thought this would be simple to solve but I am trying to put a variable within a liquid statement. I have my variable {{ loop_index }} and I want it to be within this statement : {% if settings.dropdown-[loop_index]-select %} I tried putting [...] round it but that didn't work. Basically it should say settings.dropdown-1-select, settings.dropdown-2-select. What am I doing wrong? 回答1: Create a string containing the variable name, then use the square bracket notation to access the setting