Sha256: d0ca74fc2d7aa9c96c00dda86cc47289b65de79384dc705dc21cb785867400b5

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module HandlebarsAssets
  # Change config options in an initializer:
  #
  # HandlebarsAssets::Config.path_prefix = 'app/templates'
  module Config
    extend self

    attr_writer :compiler, :compiler_path, :known_helpers, :known_helpers_only, :path_prefix, :template_namespace

    def compiler
      @compiler || 'handlebars.js'
    end

    def compiler_path
      @compiler_path || HandlebarsAssets.path
    end

    def known_helpers
      @known_helpers || []
    end

    def known_helpers_only
      @known_helpers_only || false
    end

    def options
      @options ||= generate_options
    end

    def path_prefix
      @path_prefix || 'templates'
    end

    def template_namespace
      @template_namespace || 'HandlebarsTemplates'
    end

    private

    def generate_known_helpers_hash
      known_helpers.inject({}) do |hash, helper|
        hash[helper] = true
      end
    end

    def generate_options
      options = {}
      options[:knownHelpersOnly] = true if known_helpers_only
      options[:knownHelpers] = generate_known_helpers_hash if known_helpers.any?
      options
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
handlebars_assets-0.6.4 lib/handlebars_assets/config.rb