Class: Ichiban::EJSCompiler
- Inherits:
-
Object
- Object
- Ichiban::EJSCompiler
- Defined in:
- lib/ichiban/ejs_compiler.rb
Instance Method Summary collapse
- #compile ⇒ Object
- #compile_to_str ⇒ Object
-
#initialize(ejs_file) ⇒ EJSCompiler
constructor
A new instance of EJSCompiler.
Constructor Details
#initialize(ejs_file) ⇒ EJSCompiler
Returns a new instance of EJSCompiler.
20 21 22 |
# File 'lib/ichiban/ejs_compiler.rb', line 20 def initialize(ejs_file) @ejs_file = ejs_file end |
Instance Method Details
#compile ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/ichiban/ejs_compiler.rb', line 3 def compile FileUtils.mkdir_p File.dirname(@ejs_file.dest) File.open(@ejs_file.dest, 'w') do |f| f << compile_to_str end Ichiban.logger.compilation(@ejs_file.abs, @ejs_file.dest) end |
#compile_to_str ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ichiban/ejs_compiler.rb', line 11 def compile_to_str add_preamble( EJS.compile( File.read(@ejs_file.abs) ), File.basename(@ejs_file.dest, '.js') ) end |