Builds a new template.
generator | Context for rendering |
name | The name of this template |
source | Full path to the source of this template |
destination | Full path to the destination of this template |
options | Options, including callbacks. |
# File lib/templater/actions/template.rb, line 13 13: def initialize(generator, name, source, destination, options={}) 14: self.generator = generator 15: self.name = name 16: self.source = source 17: self.destination = destination 18: self.options = options 19: end
Checks if the destination file already exists.
Boolean | true if the file exists, false otherwise. |
# File lib/templater/actions/template.rb, line 34 34: def exists? 35: ::File.exists?(destination) 36: end
Checks if the content of the file at the destination is identical to the rendered result.
Boolean | true if it is identical, false otherwise. |
# File lib/templater/actions/template.rb, line 42 42: def identical? 43: ::File.read(destination) == render if ::File.exists?(destination) 44: end
Renders the template and copies it to the destination.
# File lib/templater/actions/template.rb, line 47 47: def invoke! 48: callback(:before) 49: ::FileUtils.mkdir_p(::File.dirname(destination)) 50: ::File.open(destination, 'w') {|f| f.write render } 51: callback(:after) 52: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.