Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
user tempfile for temporary soy compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alitn committed Jan 22, 2012
1 parent 8fc1c5b commit 35b4765
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/yellow-brick-road/soy_processor.rb
@@ -1,4 +1,5 @@
require 'tilt'
require 'tempfile'

module YellowBrickRoad
class SoyProcessor < Tilt::Template
Expand Down Expand Up @@ -36,13 +37,14 @@ def evaluate scope, locals, &block

# Since SoyToJsSrcCompiler does not provide a stdout access to
# the output, the output is written to a tempfile.
tempoutput = Rails.root.join 'tmp', "soy-#{Time.now.to_i.to_s}.js"
compiler_options= @compiler_options.merge outputPathFormat: tempoutput
# tempoutput = Rails.root.join 'tmp', "soy-#{Time.now.to_i.to_s}.js"
tempfile = Tempfile.new 'soy'
compiler_options = @compiler_options.merge outputPathFormat: tempfile.path

compile compiler_options

@output = IO.read tempoutput
File.delete tempoutput
@output = IO.read tempfile.path
tempfile.unlink

@output
end
Expand Down

0 comments on commit 35b4765

Please sign in to comment.