Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在include语句jekyll中使用页面属性_Ruby_Jekyll - Fatal编程技术网

Ruby 在include语句jekyll中使用页面属性

Ruby 在include语句jekyll中使用页面属性,ruby,jekyll,Ruby,Jekyll,我有一个jekyll页面,其中有两个文件夹:products\u products/product\u name 我有一个产品页面md文件,其中包含: --- title: product_title subtitle: subtilte layout: product description: long description product_icon: product_image_path --- 这个简单的布局: --- layout: default --- <!-- Main

我有一个jekyll页面,其中有两个文件夹:
products
\u products/product\u name

我有一个产品页面md文件,其中包含:

---
title: product_title
subtitle: subtilte
layout: product
description: long description
product_icon: product_image_path
---
这个简单的布局:

---
layout: default
---
<!-- Main -->
<div id="main">
  <div id="content" class="container">
    <header id="product_header">
      <div class="half_left center">
        <img id="product_icon" src="/assets/{{ page.product_icon }}" alt="">
    <h2 id="product_title">{{ page.title }}</h2>
        <h3 id="product_subtitle">{{page.subtitle}}</h3>
      </div>
      <div class="half_right center">
        {% markdown _products/page.title/short.md %}
      </div>
      <div class="clear"></div>

    </header>
        {{content}}
  </div>
</div>
有人能告诉我如何在
{%markdown\u products/page.title/short.md%}
中捕获page.title吗?我得到了这个错误:
液体异常:没有这样的文件或目录@rb\u sysopen-/home/tools/git/pagename.github.io//u products/page.title/short in\u layouts/product.html

我在jekyll中找到了一个不同的内置解决方案,因此我不需要一个插件

假设您在path
markdown\u文件中有markdown文件
john.md
,那么我们可以执行以下操作:

{% capture john %}
    {% include_relative markdown_files/john.md %}
{% endcapture %}
然后我们想在哪里输入现在在
john
中捕获的
john.md
文本,我们可以把这个
{{john | markdownify}}

这不是一个光滑的,不是一个班轮,但它的工作。根据您的设置,您可以使用
include
而不是
include\u relative

希望它能帮助其他人,感谢Jekyll IRC社区帮助我找到解决方案

{% capture john %}
    {% include_relative markdown_files/john.md %}
{% endcapture %}