Class: Bhook::Theme
Instance Method Summary collapse
-
#initialize(theme_path) ⇒ Theme
constructor
A new instance of Theme.
- #render_page(md, src_file_sha, src_file_date, file_url) ⇒ Object
Constructor Details
#initialize(theme_path) ⇒ Theme
Returns a new instance of Theme.
9 10 11 12 13 14 |
# File 'lib/bhook/theme.rb', line 9 def initialize(theme_path) @page_template = T.let(File.read(File.join(theme_path, 'page.erb')), String) @after_h1_template = T.let(File.read(File.join(theme_path, '_after_h1.erb')), String) strategy = ->(binding_instance) { ERB.new(@after_h1_template, trim_mode: '-').result(binding_instance) } @after_h1_strategy = T.let(strategy, T.proc.params(binding_instance: Binding).returns(String)) end |
Instance Method Details
#render_page(md, src_file_sha, src_file_date, file_url) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bhook/theme.rb', line 20 def render_page(md, src_file_sha, src_file_date, file_url) src_title = T.let('', String) doc = Kramdown::Document.new(md) output, warnings = Converter::Html.convert(doc.root, doc..merge( after_h1_strategy: @after_h1_strategy, h1_callback: ->(str) { src_title = str } )) ERB.new(@page_template, trim_mode: '-').result(binding) end |