liquid

Check for existence of file using Jekyll

≯℡__Kan透↙ 提交于 2019-12-10 00:58:53
问题 How can I use Jekyll to test for the existence of a file? To clarify, I want to run an {% if %} statement to check if an image file exists with the same name as the page I am on. On my page in the YAML front matter: ---- reference-design: true ---- In my layout: {% if page.reference-design %} {% assign filename = page.path | remove_first: '.html' %} <!-- How can I check if file actually exists? --> <img src="images/reference_designs/{{ filename }}.png"> {% endif %} 回答1: As of Jekyll 2, all

Can Shopify app automatically inject liquid code inside shop's theme?

瘦欲@ 提交于 2019-12-09 15:46:04
问题 I'm building a Shopify application and I'm interested in automatically adding a liquid content into the shop's theme. 回答1: A file with a .liquid extension is considered to be an asset. Since you can add assets to a shop, the answer is yes, you can indeed inject Liquid template code into a shop's theme. If you use an App Proxy you can also send Shopify Liquid strings and Shopify will render that right in the Shop for you. Pretty neat stuff. 来源: https://stackoverflow.com/questions/13932861/can

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

瘦欲@ 提交于 2019-12-09 15:34:31
问题 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 ? 回答1: You can directly create a new empty array controllers and concat to it your

Outputting Literal curly braces in Liquid templates

半世苍凉 提交于 2019-12-09 07:35:48
问题 I'm trying to output the following from within a liquid template: {{ example }} Obviously, Liquid sees this as a variable named example and tries to do substitution. I'm trying to find out how I can output the actual braces. So far, I've found one method that works, but it's incredibly ugly: {{ '{example'|prepend:'{' }}}} Yeah, told you it was gross. Here are other things I've tried: {{{ example }}} # outputs '}' {{{{ example }}}} # outputs '}}' \{\{ example \}\} # outputs '\{\{ example \}\}'

Dynamic Variables Jekyll Liquid

大憨熊 提交于 2019-12-09 06:35:59
问题 I would like to use dynamic variables for my jekyll + liquid installation. I want to dynamically access the _config.yml file using the dynamic variable names. It is best explained with an example: Page: --- layout: default title: title_homepage --- Default Layout: {{ site.locales[site.default_locale].page.title }} _config.yml: default_locale: "en" locales: en: title_homepage: "This is my homepage title!" pirate: title_homepage: "Yaaawwwr. Homepage title." So how can I access the _config.yml

Howto check if current visitor is shop's admin?

∥☆過路亽.° 提交于 2019-12-09 03:32:47
问题 I would like to create a product that would be available in Shopify's storefront but would only be accessible for the shop administrator. Is there anyway to identify if the current user is an admin via liquid? or is there any other solution for this challenge. Thanks! 回答1: If you're signed in as an admin, when rendering the {{ content_for_header }} include, it will contain some JavaScript to push the page content down to make room for the Shopify admin bar. We can utilize capture to store the

Escaping Characters in Liquid String

断了今生、忘了曾经 提交于 2019-12-08 19:34:21
问题 I am trying to put together a tag list that contains various sizes (in Shopify using Liquid). The sizes use single and double quotes for inches and feet. Because it uses both, it is causing issues with the string closing properly. I have tried using a standard escape character '\', but that doesn't seem to work. Is it possible to escape characters in Liquid or is there another method someone can recommend? {% assign tags = "4'x6', 5'x8', 8'x10', 9'x12', 10'x14', 5'x7', 3'x5', 2'x3', 6'x9', 16

Check if variable is type of string or array in liquid

丶灬走出姿态 提交于 2019-12-08 16:12:23
问题 In Jekyll you can use liquid template and I am trying to write a nav that includes all links in the website. sitemap: home: "/" demo: right: "/right" left: "/left" What I am trying to achieve is to create a sidebar that icludes all those links. But certains links are under a section. The output should be the following <nav> <ul> <li> <a href="/">home</a> </li> </ul> <ul> <li>demo</li> <li> <a href="/right">right</a> </li> <li> <a href="/left">left</a> </li </ul> </nav> Not all sections must

What does capturing a liquid variable then assigning to nil do?

Deadly 提交于 2019-12-08 13:41:44
问题 Jekyll bootstrap includes the file _includes/JB/setup : {% capture jbcache %} <!-- - Dynamically set liquid variables for working with URLs/paths --> {% if site.JB.setup.provider == "custom" %} {% include custom/setup %} {% else %} {% if site.safe and site.JB.BASE_PATH and site.JB.BASE_PATH != '' %} {% assign BASE_PATH = site.JB.BASE_PATH %} {% assign HOME_PATH = site.JB.BASE_PATH %} {% else %} {% assign BASE_PATH = nil %} {% assign HOME_PATH = "/" %} {% endif %} {% if site.JB.ASSET_PATH %} {

Generating files by programming in Jekyll

老子叫甜甜 提交于 2019-12-08 12:35:40
问题 Suppose I have some data in the _data folder from which I want to automatically generate pages. That is: imagine _data/structure.md is something as follows chapters: - chapter1 chapter2 chapter3 ... and I need static files chapter1.md , chapter2.md ... and so on which are quite similar in structure (for instance, chapter1.md is --- title:chapter1 layout: default --- This is chapter1!! ). Is there a way to create these files automatically, without doing them by hand, just changing or adding