Class: Tilt::RadiusTemplate

Inherits:
Template show all
Defined in:
lib/tilt/radius.rb

Overview

Radius Template github.com/jlong/radius/

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Class Method Details

.context_classObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tilt/radius.rb', line 8

def self.context_class
  @context_class ||= Class.new(Radius::Context) do
    attr_accessor :tilt_scope

    def tag_missing(name, attributes)
      tilt_scope.__send__(name)
    end

    def dup
      i = super
      i.tilt_scope = tilt_scope
      i
    end
  end
end

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/tilt/radius.rb', line 44

def allows_script?
  false
end

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tilt/radius.rb', line 27

def evaluate(scope, locals, &block)
  context = self.class.context_class.new
  context.tilt_scope = scope
  context.define_tag("yield") do
    block.call
  end
  locals.each do |tag, value|
    context.define_tag(tag) do
      value
    end
  end

  options = {:tag_prefix => 'r'}.merge(@options)
  parser = Radius::Parser.new(context, options)
  parser.parse(data)
end

#prepareObject



24
25
# File 'lib/tilt/radius.rb', line 24

def prepare
end