Sha256: 5b9eac1b43e286e244597a7a80ed4e085ebff3904d694ede57bcb332631da732

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

module Sprockets
  module Mustache
    module Template
      class Generator

        attr_reader :template_name

        def initialize(namespace, logical_path, template_string, library)
          @template_name = logical_path
          @namespace = namespace
          @template_string = template_string
          @library = library
        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);
  }
}(#{@library}));
          JS

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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