move rendering into specialized File and Template rendering classes.
This commit is contained in:
parent
c06fbcfc93
commit
f40903e663
7 changed files with 380 additions and 302 deletions
|
@ -1,6 +1,3 @@
|
|||
# Using Tilt for templating
|
||||
require 'tilt'
|
||||
|
||||
# i18n Built-in
|
||||
require 'i18n'
|
||||
|
||||
|
@ -25,6 +22,8 @@ require 'middleman-core/configuration'
|
|||
require 'middleman-core/core_extensions'
|
||||
|
||||
require 'middleman-core/config_context'
|
||||
require 'middleman-core/file_renderer'
|
||||
require 'middleman-core/template_renderer'
|
||||
|
||||
# Core Middleman Class
|
||||
module Middleman
|
||||
|
@ -161,17 +160,21 @@ module Middleman
|
|||
# Template cache
|
||||
attr_reader :cache
|
||||
|
||||
attr_reader :template_context_class
|
||||
|
||||
attr_reader :generic_template_context
|
||||
delegate :link_to, :image_tag, :to => :generic_template_context
|
||||
|
||||
# Initialize the Middleman project
|
||||
def initialize(&block)
|
||||
@cache = ::Tilt::Cache.new
|
||||
@logger = ::Middleman::Logger.singleton
|
||||
@template_context_class = Class.new(Middleman::TemplateContext)
|
||||
@generic_template_context = @template_context_class.new(self)
|
||||
@config_context = ConfigContext.new(self, @template_context_class)
|
||||
|
||||
::Middleman::FileRenderer.cache.clear
|
||||
::Middleman::TemplateRenderer.cache.clear
|
||||
|
||||
# Setup the default values from calls to set before initialization
|
||||
self.class.config.load_settings(self.class.superclass.config.all_settings)
|
||||
|
||||
|
@ -199,6 +202,10 @@ module Middleman
|
|||
super
|
||||
end
|
||||
|
||||
def add_to_instance(name, &func)
|
||||
self.define_singleton_method(name, &func)
|
||||
end
|
||||
|
||||
def add_to_config_context(name, &func)
|
||||
@config_context.define_singleton_method(name, &func)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue