html - 如何在 Liquid 模板中声明换行符变量?

标签 html jekyll liquid

我想做这样的事情:

{% assign newline = "\n" %}
newline = '{{xxxx}}'

但这返回的输出为:

newline = '\n'

我期望输出为:

newline = '  
'

最佳答案

恐怕你不能使用“\n”,它是一个正则表达式片段,无法被常规 Jekyll 过滤器解析。

但是你可以找到另一种方法。

压缩CSS

您可以使用 native Jekyll sass 转换器。

  • 将 _includes/css/styles.css 重命名为 css/styles.scss

  • 为其添加标题

    ---
    # this yaml front matter, even empty, forces Jekyll to parse sass or scss
    # you can put plain css in this file, it will simply benefit from
    # compression functionalities
    ---
    html,body,div,span ....
    
  • 在 _config.yml 中配置 sass 行为

    sass:
      # style : nested (default), compact, compressed, expanded
      #         :nested, :compact, :compressed, :expanded also works
      # see http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style
      # on a typical twitter bootstrap stats are :
      # nested 138,7kB, compact 129,1kB, expanded 135,9 kB, compressed 122,4 kB
      style: compressed
    

压缩html

您只需使用 imathis html minification plugin .

然后,您将需要使用不同的工作流程将源代码发布到 Github 页面。

您可以在 Octopress Rakefile 中找到有用的灵感或者在我的works on versioning workflows适用于使用插件的网站。

关于html - 如何在 Liquid 模板中声明换行符变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25815329/

相关文章:

html - IE边框半径显示错误

javascript - 具有相同类名的jquery多个字符计数

ruby - Github Pages 上的 Jekyll 部署格式不正确(无样式)

Jekyll 按类别和优先级对集合进行分组和排序

ruby - 如何在 Jekyll 的主页上按日期对帖子进行分组?

ruby - 未返回 GitHub Pages 配置变量

javascript - 背景图片div可点击

javascript - 如何使用 JavaScript 更新/更改 HTML 内容并防止页面刷新?

jekyll - Jekyll 按月发布的帖子

github - 将 FormSpree 集成到 GitHub Jekyll 中(返回消息 : Form should post)