class Jekyll::CSU_Plugin_Zybook::ZybookTag
Public Class Methods
DEFAULTS()
click to toggle source
# File lib/jekyll-zybook-tag.rb, line 36 def self.DEFAULTS return @@DEFAULTS end
new(tag_name, markup, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-zybook-tag.rb, line 40 def initialize(tag_name, markup, tokens) super @config = {} # set defaults override_config(@@DEFAULTS) # override configuration with values defined within _config.yml if Jekyll.configuration({}).has_key?('zybook') jek_config = Jekyll.configuration({})['zybook'] override_config(jek_config) end params = markup.split if params.size > 0 # override configuration with parameters pconfig = {} # reset local config params.each do |param| param = param.gsub /\s+/, '' # remove whitespaces key, value = param.split(':',2) # split first occurrence of ':' only pconfig[key.to_sym] = value end override_config(pconfig) end end
Public Instance Methods
override_config(config)
click to toggle source
# File lib/jekyll-zybook-tag.rb, line 70 def override_config(config) config.each{ |key,value| @config[key] = value } end
render(context)
click to toggle source
Calls superclass method
# File lib/jekyll-zybook-tag.rb, line 74 def render(context) content = super rtn = "" if @config[:chapter].empty? rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/') elsif @config[:resource_id].empty? rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/chapter/#{@config[:chapter]}/section/#{@config[:section]}/' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/') else #content_resource_id was included rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/chapter/#{@config[:chapter]}/section/#{@config[:section]}?content_resource_id=#{@config[:resource_id]}' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/') end return rtn end