Add textilize filter for transforming input into HTML via RedCloth, so you can have Textile-formatted attributes other than the page's content (for example, an excerpt)
This commit is contained in:
parent
9a81255729
commit
ee65dadc9a
|
@ -307,6 +307,12 @@ becomes
|
||||||
|
|
||||||
foo, bar, and baz
|
foo, bar, and baz
|
||||||
|
|
||||||
|
h3. Textilize
|
||||||
|
|
||||||
|
Convert a Textile-formatted string into HTML, formatted via RedCloth
|
||||||
|
|
||||||
|
{{ page.excerpt | textilize }}
|
||||||
|
|
||||||
h3. Include (Tag)
|
h3. Include (Tag)
|
||||||
|
|
||||||
If you have small page fragments that you wish to include in multiple places
|
If you have small page fragments that you wish to include in multiple places
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
module Filters
|
module Filters
|
||||||
|
def textilize(input)
|
||||||
|
RedCloth.new(input).to_html
|
||||||
|
end
|
||||||
|
|
||||||
def date_to_string(date)
|
def date_to_string(date)
|
||||||
date.strftime("%d %b %Y")
|
date.strftime("%d %b %Y")
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,10 @@ class TestFilters < Test::Unit::TestCase
|
||||||
@filter = JekyllFilter.new
|
@filter = JekyllFilter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_textilize_with_simple_string
|
||||||
|
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
||||||
|
end
|
||||||
|
|
||||||
def test_array_to_sentence_string_with_no_args
|
def test_array_to_sentence_string_with_no_args
|
||||||
assert_equal "", @filter.array_to_sentence_string([])
|
assert_equal "", @filter.array_to_sentence_string([])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue