Sha256: e44e842b8fd9678aefeff52a6de2dfe49d6ecf7547d09907c0b091ff2fae7ae9
Contents?: true
Size: 502 Bytes
Versions: 44
Compression:
Stored size: 502 Bytes
Contents
require "htmlbeautifier" module Lookbook class CodeBeautifier < Service attr_reader :source, :opts def initialize(source, opts = {}) @source = source.to_s @opts = opts end def call language = opts.fetch(:language, "html") stripped_source = source.strip result = (language.downcase == "html") ? HtmlBeautifier.beautify(stripped_source, opts) : stripped_source result.to_s.strip.html_safe rescue source.strip.html_safe end end end
Version data entries
44 entries across 44 versions & 1 rubygems