Sha256: b7c635ae1f4311cfc6844abde4fc9a147914098fd8bc16cae6ef8b6d15e939a5

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 Bytes

Contents

module Sprockets
  module Mustache
    module Template
      class Generator

        attr_reader :template_name

        def initialize(namespace, logical_path, template_string)
          @template_name = logical_path
          @namespace = namespace
          @template_string = template_string
        end

        def generate

          js_function = <<-JS
(function($) {

  #{@namespace}.mustache['#{@template_name}'] = {
    template: "#{@template_string}",
    render: render
  };

  function render(obj, partials) {
    return Mustache.to_html(#{@namespace}.mustache['#{@template_name}'].template, obj, partials);
  }
}(jQuery));
          JS

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprockets_spacely-0.0.2 lib/sprockets_spacely/mustache/template/generator.rb