lib/depengine/processor/template.rb in depengine-0.0.31 vs lib/depengine/processor/template.rb in depengine-3.0.0
- old
+ new
@@ -23,11 +23,11 @@
target_path = target_root_path
Find.find( single_file || source_root_path ) do |path|
# next if we found ourself
next if path == source_root_path
-
+
sub_dir = File.join( File.dirname( path ).split(/\//) - \
source_root_path.split(/\//) )
target_path = File.join( target_root_path, sub_dir )
target = File.join( target_path, File.basename( path ) )
@@ -75,32 +75,28 @@
end
def parse(template, content)
context = load_tags(content, @cdb)
begin
- parser = Radius::Parser.new(context, :tag_prefix => 't')
+ parser = Radius::Parser.new(context, :tag_prefix => 't')
template_content = ""
result = ""
if File.file? template
- read_mode = ""
- if RUBY_VERSION < '1.9'
- read_mode = 'r'
- else
- read_mode = 'rb'
- end
- File.open(template, read_mode) do |f|
+ $log.writer.debug "tempalte #{template} seems to be a file, reading it..."
+ File.open(template, "rb") do |f|
c = ""
f.ungetc c unless (c = f.getc)=="\uFEFF" # remove BOM, if present
while line = f.gets
template_content << line
end
end
else
+ $log.writer.debug "tempalte is not a file, using it as source"
template_content = template
end
-
- result = parser.parse(template_content)
+
+ result = parser.parse(template_content)
nested_result_1 = ""
nested_result_2 = result
nested_loop = 0
while( nested_result_1 != nested_result_2 )
if nested_loop >= 100
@@ -116,10 +112,10 @@
rescue Exception => e
$log.writer.error "Error in template processing: #{template}"
$log.writer.error e.message
exit 1
end
-
+
result
end
end
end