Class: JqueryPluginGen::QuickTemplate
- Inherits:
-
Object
- Object
- JqueryPluginGen::QuickTemplate
- Defined in:
- lib/jquery_plugin_gen/quick_template.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #exec(b) ⇒ Object
-
#initialize(file, path = "") ⇒ QuickTemplate
constructor
A new instance of QuickTemplate.
Constructor Details
#initialize(file, path = "") ⇒ QuickTemplate
Returns a new instance of QuickTemplate.
9 10 11 12 13 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 9 def initialize(file, path="") @path = path.empty? ? File.join(File.dirname(__FILE__), '..', 'templates') : path @file = File.join(@path, file) + '.erb' @text = File.read(@file) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 5 def args @args end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 5 def file @file end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 5 def text @text end |
Class Method Details
.erb(file, b, path = "") ⇒ Object
30 31 32 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 30 def self.erb(file, b, path="") QuickTemplate.new(file, path).exec(b) end |
Instance Method Details
#exec(b) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jquery_plugin_gen/quick_template.rb', line 15 def exec(b) begin details = b # b = binding template = ERB.new(@text, 0, "%<>") result = template.result(binding) # Chomp the trailing newline #result.gsub(/\n$/,'') result rescue NameError puts "Error found for #{@file}" raise $! end end |