Sha256: 27ddb39442261b35c86bf16c600344107be92bcf867066c752827f3375b3351f

Contents?: true

Size: 1.01 KB

Versions: 21

Compression:

Stored size: 1.01 KB

Contents

module Volt
  class ComponentTemplates
    module Preprocessors #:nodoc:
      # Setup default handler on extend
      def self.extended(base)
        base.register_template_handler :html, BasicHandler.new
        base.register_template_handler :email, BasicHandler.new
      end

      @@template_handlers = {}

      def self.extensions
        @@template_handlers.keys
      end

      # Register an object that knows how to handle template files with the given
      # extensions. This can be used to implement new template types.
      # The handler must respond to +:call+, which will be passed the template
      # and should return the rendered template as a String.
      def register_template_handler(extension, handler)
        @@template_handlers[extension.to_sym] = handler
      end

      def registered_template_handler(extension)
        extension && @@template_handlers[extension.to_sym]
      end

      def handler_for_extension(extension)
        registered_template_handler(extension)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.7.pre7 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.7.pre6 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.7.pre5 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.7.pre3 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.7.pre2 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.6 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.6.pre3 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.6.pre2 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.6.pre1 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre12 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre11 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre9 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre8 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre7 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre6 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre5 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre4 lib/volt/server/template_handlers/preprocessors.rb
volt-0.9.5.pre3 lib/volt/server/template_handlers/preprocessors.rb