liquid

Ordinalize date formatting in Liquid/Jekyll (e.g. “1st”, “3rd” and “4th”)

一笑奈何 提交于 2019-12-19 03:20:50
问题 Is it possible to add day of the month suffixes to a date format in Liquid or Jekyll? For example: January 23rd or May 18th. I've referred to the Shopify wiki, but I'm shocked to see that there's no formatting there for it. Surely something that simple should be? :/ 回答1: The Liquid Template Engine that Jekyll uses doesn't offer the ability to ordinalize (e.g. turn "1" into "1st" and "3" into "3rd") out of the box. However, it is possible to use filters and tags to provide that functionality.

Ordinalize date formatting in Liquid/Jekyll (e.g. “1st”, “3rd” and “4th”)

旧街凉风 提交于 2019-12-19 03:20:04
问题 Is it possible to add day of the month suffixes to a date format in Liquid or Jekyll? For example: January 23rd or May 18th. I've referred to the Shopify wiki, but I'm shocked to see that there's no formatting there for it. Surely something that simple should be? :/ 回答1: The Liquid Template Engine that Jekyll uses doesn't offer the ability to ordinalize (e.g. turn "1" into "1st" and "3" into "3rd") out of the box. However, it is possible to use filters and tags to provide that functionality.

How do a loop n.times in Liquid templating using an existing for loop

≡放荡痞女 提交于 2019-12-18 16:31:30
问题 In ruby I can do n.times do, is it possible to do this in Liquid markup? My current loop is: for video in site.posts my goal is to run this loop 2 times. There are currently 4 objects that will be called through the loop but I want 8. I hope this is clear! 回答1: You should be able to use a for loop with a range ( n is the number of iterations): {% for num in (1..n) %} In some instances of Shopify Liquid, it may also work to use {% for num in (1...n) %} 回答2: If like me you want to have a

Date Math / Manipulation in Liquid Template Filter

北战南征 提交于 2019-12-18 12:49:23
问题 I'm constructing an "Integration URL" in Desk.com, which uses the Shopify Liquid Template filter syntax. This URL needs to contain a "start date" and an "end date" for a query where the start date is 7 days ago and the end date is right now. To achieve this I think I need to subtract 7 days (604800 in Epoch time) from the 'now' object and then apply my formatting but I can't figure out valid syntax for that. For the current time, this syntax is valid and working: {{'now' | date: "%b %d, %Y %I

How to get Markdown processed content in Jekyll tag plugin

青春壹個敷衍的年華 提交于 2019-12-18 12:34:08
问题 I'm working on a Jekyll tag plugin for my Octopress site to help me make a 'note' element. I just want to be able to highlight a piece of information on my blog as a side note, like this. The problem is, I can't figure out how to get the contents of this tag to be processed (i.e. Markdown or Textile). The above image is only achieved is I actually make my links with html code. Here is how it ends up turning out when I use markdown in the contents. In my post, I'm writing the contents of this

Is there a “break” tag to escape a loop in Liquid?

时间秒杀一切 提交于 2019-12-18 05:27:06
问题 How do I break out of loop in Liquid, mainly a for-loop? I've tried {% break %} , but that fails with There were errors saving your file: Unknown tag 'break' . I'm trying to achieve something like: var variants = []; {% for item in cart.items %} {% if item.product.handle == "handle-name" %} variants = {{item.product.variants | json}}; {% break %} // won't work {% endif %} {% endfor %} 回答1: For future visitors. Above code does work in current Liquid (gem v2.5.1). 来源: https://stackoverflow.com

Iterate over hashes in liquid templates

戏子无情 提交于 2019-12-17 08:31:06
问题 I'm writing a site in Jekyll, which uses Liquid. I have front matter for pages that I'd like to look like this: --- title: Designing algorithms that scale horizontally speaker: Luke Ehresman, CopperEgg category: notes.mongodallas.talks links: - demo: http://www.github.com/copperegg/mongo-scaling-demo layout: talknotes --- In Liquid, the links section of YAML comes through as: [{'demo' => 'http://www.github.com/copperegg/mongo-scaling-demo' }] I'd like to be able to iterate over the array,

How to escape liquid template tags?

对着背影说爱祢 提交于 2019-12-17 04:12:56
问题 This sounds very easy, however I couldn't find it anywhere in the docs. How can I write {% this %} in a liquid template, without it being processed by the engine? 回答1: For future searchers, there is a way to escape without plugins, use the code below: {{ "{% this " }}%} and for tags, to escape {{ this }} use: {{ "{{ this " }}}} There is also a jekyll plugin for this which makes it a whole lot easier: https://gist.github.com/1020852 Raw tag for jekyll. Keeps liquid from parsing text betweeen {

Overlapping divs in liquid layout - CSS [closed]

心已入冬 提交于 2019-12-13 21:30:32
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . So here's my problem. I am using a liquid layout on my page, so that the site always fits the width of the window. works perfectly, sounds great, right?

jekyll variables, if functions

我与影子孤独终老i 提交于 2019-12-13 14:16:37
问题 Why is something like this not working ? i try to filter all posts from this year <div class="tiles"> {% for post in site.categories.articles %} {% capture pubyear %} {{ post.date | date: "%Y" }} {% endcapture %} {% if pubyear == "2014" %} {% include post-grid.html %} {% endif %} {% endfor %} </div><!-- /.tiles --> 回答1: The problem is that it is capturing the output with some spaces in it, so it fails the if condition, remove those spaces and it should work <div class="tiles"> {% for post in