Sha256: 51b73ae569cbeaf9a79d99eece36eb0447f682cad5cdb6203bc5d99d7dd4664e

Contents?: true

Size: 1.08 KB

Versions: 53

Compression:

Stored size: 1.08 KB

Contents

module Gollum
  class Macro
    # Find the macro named, create an instance of that, and return it
    def self.instance(macro_name, wiki, page)
      begin
        self.const_get(macro_name).new(wiki, page)
      rescue NameError
        Unknown_Macro.new(macro_name)
      end
    end

    def initialize(wiki, page)
      @wiki = wiki
      @page = page
    end

    def render(*_args)
      raise ArgumentError,
            "#{self.class} does not implement #render.  "+
            "This is a bug in #{self.class}."
    end
    
    protected
    def html_error(s)
      "<p class=\"gollum-error\">#{s}</p>"
    end

    # The special class we reserve for only the finest of screwups.  The
    # underscore is to make sure nobody can define a real, callable macro
    # with the same name, because that would be... exciting.
    class Unknown_Macro < Macro
      def initialize(macro_name)
        @macro_name = macro_name
      end

      def render(*_args)
        "!!!Unknown macro: #{@macro_name}!!!"
      end
    end
  end
end

Dir[File.expand_path('../macro/*.rb', __FILE__)].each { |f| require f }

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
gitlab-gollum-lib-4.2.7.10.gitlab.2 lib/gollum-lib/macro.rb
gitlab-gollum-lib-4.2.7.10.gitlab.1 lib/gollum-lib/macro.rb
gitlab-gollum-lib-4.2.7.9 lib/gollum-lib/macro.rb
gollum-lib-5.0.4-java lib/gollum-lib/macro.rb
gollum-lib-5.0.4 lib/gollum-lib/macro.rb
gollum-lib-5.0.3-java lib/gollum-lib/macro.rb
gollum-lib-5.0.3 lib/gollum-lib/macro.rb
gollum-lib-5.0.2-java lib/gollum-lib/macro.rb
gollum-lib-5.0.2 lib/gollum-lib/macro.rb
gollum-lib-5.0.1-java lib/gollum-lib/macro.rb
gollum-lib-5.0.1 lib/gollum-lib/macro.rb
gollum-lib-5.0 lib/gollum-lib/macro.rb
gitlab-gollum-lib-4.2.7.8 lib/gollum-lib/macro.rb
gitlab-gollum-lib-4.2.7.7 lib/gollum-lib/macro.rb
gitlab-gollum-lib-4.2.7.6 lib/gollum-lib/macro.rb
gollum-lib-4.2.10-java lib/gollum-lib/macro.rb
gollum-lib-4.2.10 lib/gollum-lib/macro.rb
gollum-lib-4.2.9-java lib/gollum-lib/macro.rb
gollum-lib-4.2.9 lib/gollum-lib/macro.rb
gollum-lib-5.0.a.4-java lib/gollum-lib/macro.rb