Class Amrita::TemplateManager
In: lib/amrita/template.rb
Parent: Object
Methods
[]    clear_mem_cache    get_template    new    save_template    set_cache_dir    set_cache_dir   
Included modules
Singleton
Public Class methods
[](path)
# File lib/amrita/template.rb, line 567
    def TemplateManager::[](path)
      TemplateManager.instance.get_template(path)
    end
set_cache_dir(path)
# File lib/amrita/template.rb, line 571
    def TemplateManager::set_cache_dir(path)
      TemplateManager.instance.set_cache_dir(path)
    end
new()
# File lib/amrita/template.rb, line 587
    def initialize
      @mem_cache = MemoryCache.new
      set_cache_dir(ENV["AmritaCacheDir"].untaint)  # be careful whether this directory is safe
    end
Public Instance methods
set_cache_dir(path)

CAUTION: be careful to prevent users to edit the cache file. It's YOUR resposibility to protect the cache files from crackers. Don't use TemplateFileWithCache::set_cache_dir if you don't understand this.

# File lib/amrita/template.rb, line 579
    def set_cache_dir(path)
      if path
        @file_cache = FileCache.new(path)
      else
        @file_cache = nil
      end
    end
get_template(path)
# File lib/amrita/template.rb, line 592
    def get_template(path)
      ret = nil
      if TemplateManager::const_defined? :Templates # if output of amcc was loaded
        ret = Templates[path]
      end

      ret = @mem_cache.get_template(path) unless ret
      ret = @file_cache.get_template(path) if @file_cache and not ret
      unless ret
        ret = TemplateFile.new(path)   
        ret.auto_save = true
      end
      ret
    end
clear_mem_cache()
# File lib/amrita/template.rb, line 607
    def clear_mem_cache
      @mem_cache.clear
    end
save_template(template)
# File lib/amrita/template.rb, line 611
    def save_template(template)
      if template.path
        @mem_cache.save_template(template.path, template)
        @file_cache.save_template(template.path, template) if @file_cache
      end
    end