#{tag.render("forum:post:reader")}
} output << %{#{tag.render("forum:post:context")}
} output << %{...
}
tag "group:if_forums" do |tag|
tag.expand if tag.locals.group.forums.any?
end
desc %{
Expands if this group does not have any forums.
...
}
tag "group:unless_forums" do |tag|
tag.expand unless tag.locals.group.forums.any?
end
desc %{
Expands if this group has any topics.
...
}
tag "group:if_topics" do |tag|
tag.expand if tag.locals.group.topics.any?
end
desc %{
Expands if this group does not have any topics.
...
}
tag "group:unless_topics" do |tag|
tag.expand unless tag.locals.group.topics.any?
end
desc %{
Loops through the forums belonging to this group.
...
}
tag "group:forums" do |tag|
tag.locals.forums = tag.locals.group.forums
tag.expand
end
tag "group:forums:each" do |tag|
result = []
tag.locals.forums.each do |forum|
tag.locals.forum = forum
result << tag.expand
end
result
end
desc %{
Loops through the latest topics in all forums belonging to this group.
...
}
tag "group:latest_topics" do |tag|
count = tag.attr["count"] || 10
tag.locals.topics = tag.locals.group.topics.latest(count)
tag.expand
end
tag "group:latest_topics:each" do |tag|
result = []
tag.locals.topics.each do |topic|
tag.locals.topic = topic
result << tag.expand
end
result
end
desc %{
If the group has only one forum, this presents a simple new-topic link around the supplied text.
If it has several forums, this offers a list with the supplied text as the heading.
}
tag "group:new_topic_link" do |tag|
forums = tag.locals.group.forums
text = tag.double? ? tag.expand : "Start a new conversation"
result = ""
case forums.length
when 0
when 1
result << %{#{text}}
else
result << %{#{text}
- }
result << forums.collect{|forum| %{
- #{forum.name} }} result << "
#{tag.render('comments:summary')}
} tag.locals.posts.each do |post| tag.locals.post = post results << tag.render('comment') end results << %{#{tag.render('comment_link', 'class' => 'remote post')}