Sha256: b0a0c632069dd08b9316201f11aa6a4fb8312667bfe75dfd7157f75b529b2df5

Contents?: true

Size: 683 Bytes

Versions: 3

Compression:

Stored size: 683 Bytes

Contents

# encoding: UTF-8

module Bunch
  module Compilers
    class JST
      def initialize(file, _, path)
        @file, @path = file, path
      end

      def path
        "#{template_name}.js"
      end

      def content
        @content ||= <<-JAVASCRIPT
          (function() {
            this.JST || (this.JST = {});
            this.JST['#{template_name}'] = #{compile(@file.content)};
          })();
        JAVASCRIPT
      end

      private

      def compile(content)
        # override in subclasses
      end

      def extension
        # override in subclasses
      end

      def template_name
        @path.chomp(extension).chomp(".jst")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunch-1.0.0pre3 lib/bunch/compilers/jst.rb
bunch-1.0.0pre2 lib/bunch/compilers/jst.rb
bunch-1.0.0pre1 lib/bunch/compilers/jst.rb