yaml前面的问题在haml文件中 [英] yaml front matter in a haml file

查看:127
本文介绍了yaml前面的问题在haml文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 haml-jekyll-extension ,但我不明白如何包括yaml前置物?我有以下几种:

  --- 
用户:hello
---

%html
%title RudyIndustries
%body
%h1 Hello World! {{page.user}}

但它最终会被编译为以下html:

  user:hello 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html>
< title> RudyIndustries< / title>
< body>
< h1> Hello World! {{page.user}}< / h1>
< / body>
< / html>

如何标记yaml前端,以便它能够正确编译为html?

解决方案

使用反斜杠:

haml文件:

  \ --- 
用户:hello
\ ---
%html
%title RudyIndustries
%body
%h1 Hello World! {{page.user}}

编译为以下html:

  --- 
user:hello
---
<!DOCTYPE html PUBLIC - // W3C // // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html>
< title> RudyIndustries< / title>
< body>
< h1> Hello World! {{page.user}}< / h1>
< / body>
< / html>


I am attempting to use the haml-jekyll-extension only I do not understand how to include yaml front matter? I have the following:

---
user: hello
---
!!!
%html
  %title RudyIndustries
  %body
    %h1 Hello World! {{ page.user }}

but it ends up getting compiled into the following html:

user: hello
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <title>RudyIndustries</title>
  <body>
    <h1>Hello World! {{ page.user }}</h1>
  </body>
</html>

How to do I mark the yaml front matter such that it gets compiled into html properly?

解决方案

Use a back slash:

haml file:

\---
user: hello
\---
%html
  %title RudyIndustries
  %body
    %h1 Hello World! {{ page.user }}

compiles into the following html:

---
user: hello
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <title>RudyIndustries</title>
  <body>
    <h1>Hello World! {{ page.user }}</h1>
  </body>
</html>

这篇关于yaml前面的问题在haml文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆