Sha256: b922f0a79c10d766c8e438a402f0739c943b0c88c92ae4ae3acdc8be6c9d4abf

Contents?: true

Size: 624 Bytes

Versions: 4

Compression:

Stored size: 624 Bytes

Contents

# Based on https://github.com/josh/ruby-coffee-script
require 'execjs'
require 'pathname'

module HoganAssets
  class Hogan
    class << self
      def compile(source)
        context.eval("Hogan.compile(#{source.inspect}, {asString: true})")
      end

      private

      def context
        @context ||= ExecJS.compile(source)
      end

      def source
        @source ||= path.read
      end

      def path
        @path ||= assets_path.join('javascripts', 'hogan.js')
      end

      def assets_path
        @assets_path ||= Pathname(__FILE__).dirname.join('..','..','vendor','assets')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hogan_assets-1.0.3 lib/hogan_assets/hogan.rb
hogan_assets-1.0.2 lib/hogan_assets/hogan.rb
hogan_assets-1.0.1 lib/hogan_assets/hogan.rb
hogan_assets-1.0.0 lib/hogan_assets/hogan.rb