Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GeTOUO opened this issue May 19, 2022 · 1 comment

Comments

@GeTOUO
Copy link

GeTOUO commented May 19, 2022

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.

@GeTOUO
Copy link
Author

GeTOUO commented May 23, 2022

好吧,我修改了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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant