lib/handlebars_assets/config.rb in handlebars_assets-0.6.1 vs lib/handlebars_assets/config.rb in handlebars_assets-0.6.2
- old
+ new
@@ -1,25 +1,41 @@
module HandlebarsAssets
# Change config options in an initializer:
#
# HandlebarsAssets::Config.path_prefix = 'app/templates'
- #
- # Or in a block:
- #
- # HandlebarsAssets::Config.configure do |config|
- # path_prefix = 'app/templates'
- # end
-
module Config
extend self
- def configure
- yield self
+ attr_writer :known_helpers, :known_helpers_only, :path_prefix
+
+ def known_helpers
+ @known_helpers || []
end
- attr_writer :path_prefix
+ def known_helpers_only
+ @known_helpers_only || false
+ end
+ def options
+ options = {}
+ options[:knownHelpersOnly] = true if known_helpers_only
+ options[:knownHelpers] = known_helpers_hash if known_helpers_hash.any?
+ options
+ end
+
def path_prefix
@path_prefix ||= 'templates'
+ end
+
+ private
+
+ def generate_known_helpers_hash
+ known_helpers.inject({}) do |hash, helper|
+ hash[helper] = true
+ end
+ end
+
+ def known_helpers_hash
+ @known_helpers_hash ||= generate_known_helpers_hash
end
end
end