lib/fluent-icons/helper.rb in fluent-icons-1.0.2.190 vs lib/fluent-icons/helper.rb in fluent-icons-1.1.2.192

- old
+ new

@@ -4,19 +4,25 @@ module FluentIcons include ActionView::Helpers::TagHelper mattr_accessor :fluent_helper_cache, default: {} - def fluent(symbol, options = {}) - return '' if symbol.nil? + def fluent(symbol, options = {}, fallback_text = 'Error?') + # return symbol.class.name if symbol.nil? || !symbol.is_a?(String) || !symbol.is_a?(Symbol) cache_key = [symbol, options] + tag = fluent_helper_cache.dig(*cache_key) - unless (tag = fluent_helper_cache[cache_key]) + unless tag icon = FluentIcons::Fluent.new(symbol, options) - fluent_helper_cache[cache_key] = icon.to_svg + tag = icon.to_svg + fluent_helper_cache[cache_key] = tag end - tag&.html_safe + tag.html_safe end - alias :fluent_icon :fluent + alias :fluent_icon :fluent + + def clear_fluent_helper_cache + fluent_helper_cache.clear + end end \ No newline at end of file