Sha256: 0d77427071cc1f42a5c3cfae6996786445c3aacaf22e49b0373847ee9bc73404

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'find'
require 'barber'

module Emberprecompile
    class Compiler
        def self.compile
            fileName = "compiled/views.handlebars.js"
            source = "views/"
            output = File.new(fileName, "w")
            
            Find.find(source) do |file|
                if !FileTest.directory?(file)
                    if(file.end_with?(".handlebars"))
                        print "Compiling "+file
                        templateName = file.chomp(".handlebars")
                        templateName.slice!(source)
                        result = Barber::Ember::FilePrecompiler.call(File.read(file))
                        output.write('/* '+ templateName + ' Handlebar */')
                        output.write('Ember.TEMPLATES["' + templateName + '"] = ' + result + '')
                        print "\n"
                    end
                end
            end
            print "\n"
            print "Pre-Compiled handlebars are ready for use....\n-------------------------------------------------------\n"
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emberprecompile-0.1.2 lib/emberprecompile/compiler.rb
emberprecompile-0.1.1a lib/emberprecompile/compiler.rb