Sha256: 462901bc203ada7920a2f6a96e7eacdaba474acdfb38c8069db4988809da8c60

Contents?: true

Size: 1.12 KB

Versions: 14

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) 2020 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 FasIconInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :fas
    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="fas fa-#{icon_name} #{size_class} #{modifier}"></i>)
    end
  end
  inline_macro FasIconInlineMacro
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
j1-template-2021.0.0 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.25 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.24 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.22 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.21 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.20 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.19 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.18 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.17 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.16 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.15 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.14 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.13 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb
j1-template-2020.0.12 lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb