class Leg::Template::Context
Public Class Methods
new(template_source, tutorial, config, params)
click to toggle source
# File lib/leg/template.rb, line 49 def initialize(template_source, tutorial, config, params) @template_source = template_source @tutorial = tutorial @config = config @params = params end
Public Instance Methods
markdown(source)
click to toggle source
# File lib/leg/template.rb, line 73 def markdown(source) Leg::Markdown.render(source) end
pages()
click to toggle source
# File lib/leg/template.rb, line 77 def pages @tutorial.pages end
render(path)
click to toggle source
# File lib/leg/template.rb, line 64 def render(path) if !path.end_with? ".md" raise ArgumentError, "Only .md files are supported by render() at the moment." end contents = File.read(path) Leg::Markdown.render(contents) end
render_template()
click to toggle source
# File lib/leg/template.rb, line 56 def render_template b = binding @config.options.merge(@params).each do |name, value| b.local_variable_set(name, value) end ERB.new(@template_source).result(b) end
syntax_highlighting_css(scope)
click to toggle source
# File lib/leg/template.rb, line 81 def syntax_highlighting_css(scope) syntax_theme = @config.options[:syntax_theme] || "github" if syntax_theme.is_a? String theme = Rouge::Theme.find(syntax_theme) elsif syntax_theme.is_a? Hash theme = Class.new(Rouge::Themes::Base16) theme.name "base16.custom" theme.palette syntax_theme end theme.render(scope: scope) end