slatedocs / slate

Beautiful static documentation for your API

Home Page:https://slatedocs.github.io/slate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I ignore the failed partial to ensure that index.html is successfully generated

GeTOUO opened this issue · comments

Thanks for this project, it's great, but I have some problems and need help.

I have several hundred markdown snippets, scattered in nested markdown using <%= partial "generated-snippetsapihttp-request" %> . The error of any one of the fragments during construction will cause the final generation of index.html to fail. How can I ignore the failed partial to ensure that index.html is successfully generated.

Example:
index.html.md.erb

# Introduction
Blah
...
<%= partial "includes/master" %>

# Kittens
...

and
includes/master.md.erb

<%= partial "includes/snippets1" %>
<%= partial "includes/snippets2" %>
<%= partial "includes/snippets3" %>

if <%= partial "includes/snippets2" %> build error:

Will appear: error build/index.html;

I expect: create build/index.html.

好吧,我修改了slate目录下的config.rb 其中一部分内容,以使得在出错的时候提示但并不中断整个文档,以下是我的操作:

  1. 拷贝 config.rb 并修改其中的:
helpers do
  require './lib/toc_data.rb'
end

to

helpers do
  require './lib/toc_data.rb'

  def partial(template, options = {}, &block)
    begin
      super(template, options, &block)
    rescue
      "<aside class='warning'>文件引入失败: #{$!}</aside>"
    end
  end
end
  1. 添加挂载文件:
    VolumeBind: $(PWD)/config.rb:/srv/slate/config.rb