Sha256: 37065a7159007b7396a8a685de495d7ed8bb1107f0135bf85754a5db7bef7ae6

Contents?: true

Size: 727 Bytes

Versions: 2

Compression:

Stored size: 727 Bytes

Contents

module Lookbook
  module Tags
    def define_tag(name, args = nil, opts = {}, &block)
      name = name.to_s.downcase.underscore.to_sym
      if args.is_a? Hash
        opts = args
        args = nil
      end
      opts[:args] = args
      opts[:parser] = block if block
      Lookbook.config.preview_tags[name] = opts
    end

    def self.process_tags(tag_objects, file: nil, eval_scope: nil)
      return [] if tag_objects.none?
      tag_objects.map do |tag_object|
        opts = Lookbook.config.preview_tags[tag_object.tag_name] || {}
        Lookbook::Tag.new(tag_object,
          opts[:args],
          **opts.except(:args),
          file: file,
          eval_scope: eval_scope)
      end.compact
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.1.1 lib/lookbook/tags.rb
lookbook-1.1.0 lib/lookbook/tags.rb