Class: Asciidoctor::DocTest::NoFallbackTemplateConverter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Asciidoctor::DocTest::NoFallbackTemplateConverter
- Defined in:
- lib/asciidoctor/doctest/no_fallback_template_converter.rb
Overview
TemplateConverter that doesn’t fallback to a built-in converter when no template for a node is found.
Constant Summary collapse
- NOT_FOUND_MARKER =
Placeholder to be written in a rendered output in place of the node’s content that cannot be rendered due to missing template.
'--TEMPLATE NOT FOUND--'
Instance Method Summary collapse
-
#convert(node, template_name = nil, opts = {}) ⇒ Object
(also: #convert_with_options)
Delegates to the template converter and returns results, or prints warning and returns NOT_FOUND_MARKER if there is no template to handle the specified
template_name
. -
#initialize(backend, opts = {}) ⇒ NoFallbackTemplateConverter
constructor
A new instance of NoFallbackTemplateConverter.
Constructor Details
#initialize(backend, opts = {}) ⇒ NoFallbackTemplateConverter
Returns a new instance of NoFallbackTemplateConverter.
20 21 22 |
# File 'lib/asciidoctor/doctest/no_fallback_template_converter.rb', line 20 def initialize(backend, opts = {}) super Asciidoctor::Converter::TemplateConverter.new(backend, opts[:template_dirs], opts) end |
Instance Method Details
#convert(node, template_name = nil, opts = {}) ⇒ Object Also known as: convert_with_options
Delegates to the template converter and returns results, or prints warning and returns NOT_FOUND_MARKER if there is no template to handle the specified template_name
.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/asciidoctor/doctest/no_fallback_template_converter.rb', line 28 def convert(node, template_name = nil, opts = {}) template_name ||= node.node_name if handles? template_name super else warn "Could not find a custom template to handle template_name: #{template_name}" NOT_FOUND_MARKER end end |