Sha256: 4de5ecf86bd99c88fb67b4273261b65953742759df0df17aeeed67b16880efe3

Contents?: true

Size: 1.12 KB

Versions: 74

Compression:

Stored size: 1.12 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/fas-icon-inline.rb
# Asciidoctor extension for J1 Template
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2021 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
#
# ------------------------------------------------------------------------------
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

Asciidoctor::Extensions.register do
  class FabIconInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :fab
    name_positional_attributes 'size', 'modifier'
    default_attrs 'size' => '1x', 'modifier' => ''

    def process parent, target, attributes
      doc = parent.document
      size_class = (size = attributes['size']) ? %(fa-#{size}) : nil
      modifier_class = (modifier = attributes['modifier']) ? %(#{modifier}) : nil
      icon_name = target.tr '_', '-'
      %(<i class="fab fa-#{icon_name} #{size_class} #{modifier}"></i>)
    end
  end
  inline_macro FabIconInlineMacro
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
j1-template-2021.1.24 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.23 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.22 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.21 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.20 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.19 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.18 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.17 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.16 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.14 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.13 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.12 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.11 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.10 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.9 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.8 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.7 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.6 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.5 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb
j1-template-2021.1.4 lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb