Sha256: 97513cba7063b6115c8230463c3c97264dd30e43bb5a103743114318075fdcf2

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

module HandlebarsAssets
  class TiltHandlebarsTest < Test::Unit::TestCase
    include SprocketsScope

    def hbs_edge_compiled(template_name)
      <<END_EXPECTED
          (function() {
            this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
            this.HandlebarsTemplates[\"#{template_name}\"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  helpers = helpers || Handlebars.helpers;
  var buffer = \"\", stack1, foundHelper, functionType=\"function\", escapeExpression=this.escapeExpression;


  buffer += \"This is \";
  foundHelper = helpers.handlebars;
  if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); }
  else { stack1 = depth0.handlebars; stack1 = typeof stack1 === functionType ? stack1() : stack1; }
  buffer += escapeExpression(stack1);
  return buffer;});
            return this.HandlebarsTemplates[\"#{template_name}\"];
          }).call(this);
END_EXPECTED
    end

    def teardown
      HandlebarsAssets::Config.reset!
      HandlebarsAssets::Handlebars.reset!
    end

    def test_edge_compile
      root = '/myapp/app/assets/templates'
      file = 'test_render.hbs'
      scope = make_scope root, file

      HandlebarsAssets::Config.compiler_path = File.expand_path '../../edge', __FILE__

      template = HandlebarsAssets::TiltHandlebars.new(scope.pathname.to_s) { "This is {{handlebars}}" }

      assert_equal hbs_edge_compiled('test_render'), template.render(scope, {})
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
handlebars_assets-0.7.1 test/handlebars_assets/tilt_edge_test.rb
handlebars_assets-0.7.0 test/handlebars_assets/tilt_edge_test.rb
handlebars_assets-0.6.7 test/handlebars_assets/tilt_edge_test.rb
handlebars_assets-0.6.6 test/handlebars_assets/tilt_edge_test.rb
handlebars_assets-0.6.5 test/handlebars_assets/tilt_edge_test.rb
handlebars_assets-0.6.4 test/handlebars_assets/tilt_edge_test.rb