File: utils.rb

package info (click to toggle)
ruby-hamlit 2.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,332 kB
  • sloc: ruby: 10,583; ansic: 550; sh: 23; makefile: 9
file content (18 lines) | stat: -rw-r--r-- 383 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true
module Hamlit
  module Utils
    if /java/ === RUBY_PLATFORM # JRuby
      require 'cgi/escape'

      def self.escape_html(html)
        CGI.escapeHTML(html.to_s)
      end
    else
      require 'hamlit/hamlit' # Hamlit::Utils.escape_html
    end

    def self.escape_html_safe(html)
      html.html_safe? ? html : escape_html(html)
    end
  end
end