Made it possible to enter categories from YAML as an array.
This commit is contained in:
parent
2569e9fb5e
commit
0ec9a1330a
|
@ -49,7 +49,13 @@ module Jekyll
|
|||
if self.data.has_key?('category')
|
||||
self.categories << self.data['category']
|
||||
elsif self.data.has_key?('categories')
|
||||
self.categories = self.data['categories'].split
|
||||
# Look for categories in the YAML-header, either specified as
|
||||
# an array or a string.
|
||||
if self.data['categories'].kind_of? String
|
||||
self.categories = self.data['categories'].split
|
||||
else
|
||||
self.categories = self.data['categories']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
layout: default
|
||||
title: Array categories in YAML
|
||||
categories:
|
||||
- foo
|
||||
- bar
|
||||
- baz
|
||||
---
|
||||
|
||||
Best *post* ever
|
|
@ -87,10 +87,16 @@ class TestPost < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_yaml_categories
|
||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-categories.textile")
|
||||
assert p.categories.include?('foo')
|
||||
assert p.categories.include?('bar')
|
||||
assert p.categories.include?('baz')
|
||||
p1 = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '',
|
||||
"2009-01-27-categories.textile")
|
||||
p2 = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '',
|
||||
"2009-01-27-array-categories.textile")
|
||||
|
||||
[p1, p2].each do |p|
|
||||
assert p.categories.include?('foo')
|
||||
assert p.categories.include?('bar')
|
||||
assert p.categories.include?('baz')
|
||||
end
|
||||
end
|
||||
|
||||
def test_render
|
||||
|
|
Loading…
Reference in New Issue