Sha256: 908355a7204f230652474a4e36724f33e6f6008f9b7b1fd113550294a68c1413

Contents?: true

Size: 835 Bytes

Versions: 8

Compression:

Stored size: 835 Bytes

Contents

module Rasputin
  class HandlebarsTemplate < Tilt::Template
    def self.default_mime_type
      'application/javascript'
    end

    def prepare; end

    def evaluate(scope, locals, &block)
      if Rails.configuration.rasputin.precompile_handlebars
        func = Rasputin::Handlebars.compile(data)
        "Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}] = Ember.Handlebars.template(#{func});"
      else
        "Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}] = Ember.Handlebars.compile(#{indent(data).inspect});"
      end
    end

    private
    
    def template_path(path)
      path = path.split('/')
      path.delete('templates')
      path.join(Rails.configuration.rasputin.template_name_separator)
    end

    def indent(string)
      string.gsub(/$(.)/m, "\\1  ").strip
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rasputin-0.15.0 lib/rasputin/handlebars/template.rb
rasputin-0.14.1 lib/rasputin/handlebars/template.rb
rasputin-0.14.0 lib/rasputin/handlebars/template.rb
rasputin-0.13.2 lib/rasputin/handlebars/template.rb
rasputin-0.13.1 lib/rasputin/handlebars/template.rb
rasputin-0.12.1 lib/rasputin/handlebars/template.rb
rasputin-0.11.3 lib/rasputin/handlebars/template.rb
rasputin-0.11.1 lib/rasputin/handlebars/template.rb