Skip to content

Commit

Permalink
fix potential threading issue with Radius template
Browse files Browse the repository at this point in the history
  • Loading branch information
trans committed May 15, 2010
1 parent 2d09647 commit 592e2ac
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/tilt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -763,24 +763,25 @@ def initialize_engine
end

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

def evaluate(scope, locals, &block)
@context.define_tag("yield") do
context = Class.new(Radius::Context).new
context.define_tag("yield") do
block.call
end
(class << @context; self; end).class_eval do
locals.each do |tag, value|
context.define_tag(tag) do
value
end
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
scope.__send__(tag) # any way to support attr as args?
end
end
options = {:tag_prefix => 'r'}.merge(@options)
parser = Radius::Parser.new(@context, options)
parser = Radius::Parser.new(context, options)
parser.parse(data)
end
end
Expand Down

0 comments on commit 592e2ac

Please sign in to comment.