Sha256: ec36a1cc1d6adb979440ac19189002f49f5486ab8477025931a132951c945961

Contents?: true

Size: 987 Bytes

Versions: 15

Compression:

Stored size: 987 Bytes

Contents

# HoboSupport - XSS helpers

    >> require 'active_support'
    >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_support/lib')
    >> require 'hobo_support'

## `safe_join`

Version of Array#join that preserves html\_safe:

    >> $,=nil
    >> ["<a>", "<b>"].safe_join
    => "&lt;a&gt;&lt;b&gt;"

    >> ["<a>", "<b>"].safe_join.html_safe?
    => true

    >> ["<a>".html_safe, "<b>"].safe_join
    => "<a>&lt;b&gt;"

    >> ["<a>".html_safe, "<b>"].safe_join.html_safe?
    => true

    >> ["<a>".html_safe, "<b>".html_safe].safe_join
    => "<a><b>"

    >> ["<a>".html_safe, "<b>".html_safe].safe_join.html_safe?
    => true

    >> ["<a>", "<b>"].safe_join("<br>")
    => "&lt;a&gt;&lt;br&gt;&lt;b&gt;"

    >> ["<a>", "<b>"].safe_join("<br>").html_safe?
    => true

    >> ["<a>".html_safe, "<b>".html_safe].safe_join("<br>")
    => "<a>&lt;br&gt;<b>"

    >> ["<a>".html_safe, "<b>".html_safe].safe_join("<br>".html_safe)
    => "<a><br><b>"



Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hobo_support-2.2.6 test/hobosupport/xss.rdoctest
hobo_support-2.2.5 test/hobosupport/xss.rdoctest
hobo_support-2.2.4 test/hobosupport/xss.rdoctest
hobo_support-2.2.3 test/hobosupport/xss.rdoctest
hobo_support-2.2.2 test/hobosupport/xss.rdoctest
hobo_support-2.2.1 test/hobosupport/xss.rdoctest
hobo_support-2.2.0 test/hobosupport/xss.rdoctest
hobo_support-2.1.2 test/hobosupport/xss.rdoctest
hobo_support-2.1.1 test/hobosupport/xss.rdoctest
hobo_support-2.1.0 test/hobosupport/xss.rdoctest
hobo_support-2.1.0.pre4 test/hobosupport/xss.rdoctest
hobo_support-2.1.0.pre3 test/hobosupport/xss.rdoctest
hobo_support-2.1.0.pre2 test/hobosupport/xss.rdoctest
hobo_support-2.1.0.pre1 test/hobosupport/xss.rdoctest
hobo_support-2.0.1 test/hobosupport/xss.rdoctest