liquid

Jekyll & Liquid: Output category list with post count?

断了今生、忘了曾经 提交于 2019-12-04 07:53:40
问题 I'm somehow stuck and don't find the right way to do it. I want to output a category list with the number of posts in each categorie. I got this far: https://paste.xinu.at/dOLtod/ but I never managed to get the real count. I tried so many ways and nothing worked, for example going through each post and checked on every category if it equals {{ category | first }}. Here is the code without the count: <ul class="dropdown-menu"> {% for category in site.categories %} <li class="camelize_me"> <a

Ignore parts of sass file for parsing

心已入冬 提交于 2019-12-04 04:02:12
I'm trying to get SASS to ignore part of my .scss code while parsing. It's for a shopify theme that I'm making. My scss files are compiled into .css.liquid files so that I can put shopify's templating language liquid into the css too. I want the compiled css.liquid to look like this: .header--logo { background: url({{ 'header-logo.png' | asset_url }}) 0 0 no-repeat; } In LESS I used to do this: .header--logo { background: ~"{{ 'header-logo.png' | asset_url }}" 0 0 no-repeat; } Does SASS also have an easy way to do the same? Thanks! Sass doesn't provide an escape-all-the-declaration feature. To

How to link to a page with page.url without the html extension in Jekyll?

一笑奈何 提交于 2019-12-04 03:03:54
问题 I'm building a website in Jekyll. To remove html extension in posts I added the following to _config.yml permalink: /kb/:title To remove html extension from pages, I created folders for each page, and placed an index.html file in each page folder. Now the posts and pages work without html extension, but when I link to a page with page.url it returns the whole link (/kb/index.html) instead of just /kb. What variable can I use to link to a page without html extension? 回答1: The value returned by

How to create an array in a for loop in Liquid?

戏子无情 提交于 2019-12-04 02:15:22
I'm trying to create an array from a list of objects using Liquid syntax: {% for operation in menuItems %} {% assign words1 = operation.Title | split: '_' %} {% assign controllerName = words1 | first %} {% assign controllersTmp = controllersTmp | append: '_' | append: controllerName %} {% endfor %} I want to split the controllersTmp to get my array, but at this point my controllersTmp is empty. Any help ? You can directly create a new empty array controllers and concat to it your controllerName converted into an array using the workaround split:'' . The result is directly an array, without the

How to render Handlebars markup from a Liquid template (Jekyll)

核能气质少年 提交于 2019-12-04 00:14:30
I am using Jekyll for our blog and rendering Handlebars templates is a pain. We have to escape like so: {% highlight html %} <div>{{"{{code"}}}}</div> {% endhighlight %} It's fugly. Is there an easier way to do this? I found the answer: {% highlight html %} {% raw %} <div>{{code}}</div> {% endraw %} {% endhighlight %} 来源: https://stackoverflow.com/questions/14209942/how-to-render-handlebars-markup-from-a-liquid-template-jekyll

How to pass {% captured %} variable from a view to the layout in Jekyll/Liquid?

非 Y 不嫁゛ 提交于 2019-12-03 22:53:47
I am trying to rebuild a blog in Jekyll and I have stubled upon a simple task. Provided I have the following set of templates: default.html: {{ head }} {{ content }} frontpage.html: --- layout: default --- {% capture head %} Frontpage {% end %} {{ content }} index.html: --- layout: frontpage --- Other stuff I was expecting that {% capture head %} would pass a variable to layout. But it seems only variables from the Front Matter are actually being passed as page.variable_name . Is there a way to pass capture -d var to the layout in Jekyll? Guess I could make 2 different layouts for frontpage

Hierarchical Categories in GitHub Pages

╄→гoц情女王★ 提交于 2019-12-03 19:50:16
问题 I'm using Jekyll on GitHub pages, and I want to have hierarchical categories like this: animals -> mammals -> cats -> _posts -> housecat.md, tiger.md animals -> mammals -> dogs -> _posts -> poodle.md, doberman.md animals -> reptiles -> lizards -> _posts -> iguana.md, chameleon.md I'd like users to be able to visit /animals and see a listing of every post from every category. But if they go to /animals/mammals , they'd only see mammals. If they go to /animals/mammals/cats , then they only see

DotLiquid/Liquid access to dictionary

泪湿孤枕 提交于 2019-12-03 16:34:18
I am using DotLiquid template engine and trying access dictionary value in template. I have passed to template this drop: public class SomeDrop : Drop { public Dictionary<string, object> MyDictionary {get; set;} } var someDropInstance = SomeDrop { MyDictionary = new Dictionary<string, object> {{"myKey", 1}} } Template.NamingConvention = new CSharpNamingConvention(); var preparedTemplate = Template.Parse(template); var templateOutput = preparedTemplate.Render(Hash.FromAnonymousObject(new { @this = someDropInstance })); In template i can't access to myKey value as {{ this.MyDictionary.myKey }}

Get the difference in days between two dates in Jekyll

走远了吗. 提交于 2019-12-03 15:19:45
I would like to get the difference in days between two dates in Jekyll. How can I achieve this? {% capture currentDate %}{{ site.time | date: '%Y-%m-%d' }}{% endcapture %} {{currentDate}} {% capture event_date %}{{ entry.date }}{% endcapture %} {% if event_date < currentDate %}Yes{% else %}No{% endif %} In the entry there is my YAML: --- title: ChartLine C3 type: charts description: Chart with round for prisma id: c3-1 date: 2015-07-18 --- If all you want to do is know whether a date from your Front Matter is earlier than the system time then you can use the ISO 8601 date format and rely on

How to suppress blank line in Jekyll?

元气小坏坏 提交于 2019-12-03 15:09:58
问题 I use GitHub Pages for my blog, and am running into a problem with Jekyll. My post.html has a block like this: {% for testpost in site.posts %} {% four %} {% lines of %} {% processing %} {% goes here %} {% endfor %} The part in the middle doesn't matter. The important part is the end of the line which is outside of the {% %} markup, and is therefore rendered into the html. Since this is in a loop, it's putting about 1000 blank lines into the middle of by HTML page. It doesn't affect the