Sha256: 43d61376ded0e48e2e01a0b6efe6237fa43784ba3710987b1135896bbcceaebf

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

# coding: utf-8
require 'mustache'                   # extendending implementation of

module Sbuilder

  # Abstract base class, implmenting common template methods. 
  # 
  # @abstract
  class TemplateRoot < Mustache

    include Sbuilder::Utils::MyLogger   # mix logger
    PROGNAME = nil

    extend Forwardable               # for easy delegation
    def_delegators :reader,
                   :get_template,
                   :controller

    attr_reader :reader
    # ------------------------------------------------------------------
    # @!group Constructor && config
    # 
    
    def initialize(  reader, options={} )

      # inject reader
      #@reader = Sbuilder::TemplateReader.new( options )
      @reader = reader
      
      @logger = getLogger( PROGNAME, options )
      @logger.info( "#{__method__} created" )
    
    end

    # @!endgroup
    
    # ------------------------------------------------------------------
    # @!group Mustache extenstion points

    # method used by mustache framework - delegate to 'get_partial',
    # which must be implemented by concrete child class
    
    def partial(name)
      @logger.debug( "#{__method__} name=#{name}" )

      # return resolve_partial_direct(name[2..-1])  if name[0..1]  == '!!'
      # get_partial( resolve_partial_name(name) )
      get_partial( name )      
    end

    # @!endgroup    

    # ------------------------------------------------------------------
    # @!group Services offered to concrete sub-classes


    # Is template extension point?
    #
    # @param template_name [String] name of template to check
    #
    def is_extension_point( template_name )
      controller.is_extension_point( template_name )
    end
    

    # @!endgroup        


  end # class
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tla-sbuilder-0.3.9 lib/sbuilder/mustache/template_root.rb
tla-sbuilder-0.3.8 lib/sbuilder/mustache/template_root.rb
tla-sbuilder-0.3.7 lib/sbuilder/mustache/template_root.rb
tla-sbuilder-0.3.4 lib/sbuilder/mustache/template_root.rb