Class: Frank::RadiusTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/frank/tilt_setup.rb

Overview

Radius Template github.com/jlong/radius/

Instance Method Summary collapse

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/frank/tilt_setup.rb', line 49

def evaluate(scope, locals, &block)
  @context.define_tag("yield") do
    block.call
  end
  (class << @context; self; end).class_eval do
    define_method :tag_missing do |tag, attr, &block|
      if locals.key?(tag.to_sym)
        locals[tag.to_sym]
      else
        scope.__send__(tag)  # any way to support attr as args?
      end
    end
  end
  # TODO: how to config tag prefix?
  parser = Radius::Parser.new(@context, :tag_prefix => 'r')
  parser.parse(data)
end

#initialize_engineObject



40
41
42
43
# File 'lib/frank/tilt_setup.rb', line 40

def initialize_engine
  return if defined? ::Radius
  require_template_library 'radius'
end

#prepareObject



45
46
47
# File 'lib/frank/tilt_setup.rb', line 45

def prepare
  @context = Class.new(Radius::Context).new
end