Class: L::Template::TargetRenderer

Inherits:
R::TargetSmart show all
Defined in:
lib/rub/l/template.rb

Instance Attribute Summary

Attributes inherited from R::TargetSmart

#input, #output

Instance Method Summary collapse

Methods inherited from R::TargetSmart

#build, #clean, #clean?

Methods inherited from R::Target

#build, #clean?, #description, #hash_input, #hash_output, #hash_outputs, #hash_self, #input, #output, #register

Constructor Details

#initialize(inp, out, values) ⇒ TargetRenderer

Returns a new instance of TargetRenderer.



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rub/l/template.rb', line 44

def initialize(inp, out, values)
	super()
	
	@template = inp
	@resultf  = out
	
	if inp.is_a? Pathname
		input << inp
	end
	output << out
	
	@renderer = Renderer.new values
end

Instance Method Details

#build_selfObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rub/l/template.rb', line 58

def build_self
	r = if @template.is_a? String
		@renderer.render @template
	else
		@renderer.render_file @template
	end
	
	@resultf.dirname.mkpath
	@resultf.open('w') do |f|
		f.write r
	end
	
	bs = R::BuildStep.new
	bs.desc = "Rendering #{@resultf}"
	bs.print
end