mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-04 01:25:14 -07:00
StandardFilters
- added escape_once, based on ActionView
This commit is contained in:
@@ -29,6 +29,10 @@ module Liquid
|
|||||||
CGI.escapeHTML(input) rescue input
|
CGI.escapeHTML(input) rescue input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def escape_once(input)
|
||||||
|
ActionView::Helpers::TagHelper.escape_once(input) rescue input
|
||||||
|
end
|
||||||
|
|
||||||
alias_method :h, :escape
|
alias_method :h, :escape
|
||||||
|
|
||||||
# Truncate a string down to x characters
|
# Truncate a string down to x characters
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|||||||
assert_equal '<strong>', @filters.h('<strong>')
|
assert_equal '<strong>', @filters.h('<strong>')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_escape_once
|
||||||
|
assert_equal '<strong>', @filters.escape_once(@filters.escape('<strong>'))
|
||||||
|
end
|
||||||
|
|
||||||
def test_truncatewords
|
def test_truncatewords
|
||||||
assert_equal 'one two three', @filters.truncatewords('one two three', 4)
|
assert_equal 'one two three', @filters.truncatewords('one two three', 4)
|
||||||
assert_equal 'one two...', @filters.truncatewords('one two three', 2)
|
assert_equal 'one two...', @filters.truncatewords('one two three', 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user