Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from Mogztter/issue-7
Browse files Browse the repository at this point in the history
Resoles #7, set the `filename` option
  • Loading branch information
ggrossetie committed Feb 18, 2017
2 parents 8e68e70 + 54a765c commit b42be03
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/asciidoctor/core_ext/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def initialize backend, template_dirs, opts = {}
end

def handles? name
!(resolve_template name).nil?
template, content = resolve_template(name)
!template.nil?
end

def resolve_template name
Expand All @@ -28,18 +29,18 @@ def resolve_template name
engine_dir = (::File.join template_dir, engine)
template = ::File.join(engine_dir, name + "." + engine)
if (content = try_read template)
return content
return template, content
end
end
# -- end

# example: templates
template = ::File.join(template_dir, name + "." + engine)
if (content = try_read template)
return content
return template, content
end
end
return nil
return nil, nil
end

def try_read name
Expand All @@ -51,7 +52,8 @@ def try_read name

def convert node, template_name = nil, opts = {}
template_name ||= node.node_name
unless (template = resolve_template template_name)
template, content = resolve_template(template_name)
unless content
raise %(Could not find a custom template to handle transform: #{template_name})
end

Expand All @@ -61,7 +63,7 @@ def convert node, template_name = nil, opts = {}
} else if (typeof require !== 'undefined') {
var jade = jade || require('jade');
}
var compiled = jade.compile(#{template}, {pretty: true});
var compiled = jade.compile(#{content}, {pretty: true, filename: #{template}});
return compiled({ node: #{node} });
)
end
Expand Down

0 comments on commit b42be03

Please sign in to comment.