Skip to content

Instantly share code, notes, and snippets.

@mcasperson
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save mcasperson/11274338 to your computer and use it in GitHub Desktop.

Select an option

Save mcasperson/11274338 to your computer and use it in GitHub Desktop.
asciidoctor.js in Fedora 20
sudo yum install ruby-devel rubygem-bundler rubygem-rake
renderer.rb
replace with this
backend = options[:backend]
if ::RUBY_ENGINE_OPAL && backend == 'html5'
::Template.instance_variable_get('@_cache').each do |path, tmpl|
@views[(File.basename path)] = tmpl
end
else
case backend
when 'html5', 'docbook45', 'docbook5'
eruby = load_eruby options[:eruby]
require 'asciidoctor/backends/base_template'
#require "asciidoctor/backends/#{backend}"
# Load up all the template classes that we know how to render for this backend
BaseTemplate.template_classes.each do |tc|
if tc.to_s.downcase.include?('::' + backend + '::') # optimization
view_name, view_backend = self.class.extract_view_mapping(tc)
if view_backend == backend
@views[view_name] = tc.new(view_name, backend, eruby)
end
end
end
else
Debug.debug { "No built-in templates for backend: #{backend}" }
end
end
replace render method with
# Public: Render an Asciidoc object with a specified view template.
#
# view - the String view template name.
# object - the Object to be used as an evaluation scope.
# locals - the optional Hash of locals to be passed to Tilt (default {}) (also ignored, really)
def render(view, object, locals = {})
fixed_view = view.sub("_", "");
if !@views.has_key? view
if !@views.has_key? fixed_view
raise "Couldn't find a view in @views for #{view}"
else
view = fixed_view
end
end
if @chomp_result
@views[view].render(object, locals).chomp
else
@views[view].render(object, locals)
end
end
asciidoctor.rb
# backends
if ::RUBY_ENGINE_OPAL
require 'asciidoctor/backends/html5-erb'
require 'asciidoctor/backends/docbook45'
require 'asciidoctor/backends/docbook5'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment