Sha256: b5260ca19a071b928eaeee6f6283e41ddc676c07ee6998389956a61172b4986c

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require "jekyll"
require "liquid"

require "jekyll-html/start_tag"
require "jekyll-html/end_tag"

module Jekyll
  module HTML

    class << self
      def generate_start_tag(tag_content)
        raise("Tag content cannot be null!") if tag_content.nil?
        raise("Tag content cannot be empty!") if tag_content.empty?

        content = tag_content.split(" ")
        raise("Splitted content cannot be empty!") if content.empty?

        result = ""

        content.each do |target|
          target_content = target.split("=")
          if target_content.length != 2
            result += target + " "
            next
          end

          key = target_content[0]
          value = target_content[1].tr("_", " ")

          result += "#{key}=\"#{value}\"\""
        end

        "<#{result[0, result.length - 1]}>"
      end

      def generate_end_tag(tag_content)
        raise("Tag content cannot be null!") if tag_content.nil?
        raise("Tag content cannot be empty!") if tag_content.empty?

        content = tag_content.split(" ")
        raise("Splitted content cannot be empty!") if content.empty?

        "</#{content[0]}>"
      end
    end

  end
end

Liquid::Template.register_tag("st", Jekyll::HTML::StartTag)
Liquid::Template.register_tag("et", Jekyll::HTML::EndTag)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-html-1.0.2 lib/jekyll-html.rb