Merge pull request #2880 from kansaichris/slugify-liquid-filter
This commit is contained in:
commit
c3dc5cceee
|
@ -47,6 +47,17 @@ module Jekyll
|
||||||
converter.convert(input)
|
converter.convert(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Slugify a filename or title.
|
||||||
|
#
|
||||||
|
# input - The filename or title to slugify.
|
||||||
|
#
|
||||||
|
# Returns the given filename or title as a lowercase String, with every
|
||||||
|
# sequence of spaces and non-alphanumeric characters replaced with a
|
||||||
|
# hyphen.
|
||||||
|
def slugify(input)
|
||||||
|
Utils.slugify(input)
|
||||||
|
end
|
||||||
|
|
||||||
# Format a date in short format e.g. "27 Jan 2011".
|
# Format a date in short format e.g. "27 Jan 2011".
|
||||||
#
|
#
|
||||||
# date - the Time to format.
|
# date - the Time to format.
|
||||||
|
|
|
@ -211,6 +211,17 @@ common tasks easier.
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p class="name"><strong>Slugify</strong></p>
|
||||||
|
<p>Convert a string into a lowercase URL "slug" by replacing every sequence of spaces and non-alphanumeric characters with a hyphen.</p>
|
||||||
|
</td>
|
||||||
|
<td class="align-center">
|
||||||
|
<p>
|
||||||
|
<code class="filter">{% raw %}{{ page.title | slugify }}{% endraw %}</code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p class="name"><strong>Data To JSON</strong></p>
|
<p class="name"><strong>Data To JSON</strong></p>
|
||||||
|
|
|
@ -217,5 +217,11 @@ class TestFilters < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "slugify filter" do
|
||||||
|
should "return a slugified string" do
|
||||||
|
assert_equal "q-bert-says", @filter.slugify(" Q*bert says @!#?@!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue