Đây có lẽ là một câu hỏi ngớ ngẩn nhưng tôi tự hỏi liệu có cách nào để có đánh dấu được tạo ra trong Jekyll để duy trì sự thụt đầu dòng của Liquid-tag hay không. Thế giới không kết thúc nếu nó không thể giải quyết được. Tôi chỉ tò mò vì tôi thích mã của tôi trông gọn gàng, ngay cả khi biên soạn. :)Đánh dấu tạo ra thụt lề trong Jekyll/Ruby
Ví dụ tôi có hai:
base.html:
<body>
<div id="page">
{{content}}
</div>
</body>
index.md:
---
layout: base
---
<div id="recent_articles">
{% for post in site.posts %}
<div class="article_puff">
<img src="/resources/images/fancyi.jpg" alt="" />
<h2><a href="{{post.url}}">{{post.title}}</a></h2>
<p>{{post.description}}</p>
<a href="{{post.url}}" class="read_more">Read more</a>
</div>
{% endfor %}
</div>
Vấn đề là nhập khẩu {{content}} - được hiển thị mà không có sự đánh dấu được sử dụng ở trên.
Vì vậy, thay vì
<body>
<div id="page">
<div id="recent_articles">
<div class="article_puff">
<img src="/resources/images/fancyimage.jpg" alt="" />
<h2><a href="/articles/2012/11/14/gettin-down-with-rwd.html">Gettin' down with responsive web design</a></h2>
<p>Everyone's talking about it. Your client wants it. You need to code it.</p>
<a href="/articles/2012/11/14/gettin-down-with-rwd.html" class="read_more">Read more</a>
</div>
</div>
</div>
</body>
tôi nhận được
<body>
<div id="page">
<div id="recent_articles">
<div class="article_puff">
<img src="/resources/images/fancyimage.jpg" alt="" />
<h2><a href="/articles/2012/11/14/gettin-down-with-rwd.html">Gettin' down with responsive web design</a></h2>
<p>Everyone's talking about it. Your client wants it. You need to code it.</p>
<a href="/articles/2012/11/14/gettin-down-with-rwd.html" class="read_more">Read more</a>
</div>
</div>
</div>
</body>
Có vẻ như chỉ dòng đầu tiên được thụt vào một cách chính xác. Phần còn lại bắt đầu từ đầu của dòng ... Vì vậy, nhập khẩu multiline lỏng-templating? :)
Có ai từng đưa ra giải pháp trực tiếp tạo đánh dấu thụt lề đúng cách không? – mb21