mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-27 20:38:48 +01:00
Add Tag#label method
This commit is contained in:
parent
f56fc1945c
commit
95a4ed6e4a
4 changed files with 10 additions and 2 deletions
|
|
@ -3,7 +3,7 @@ module RecurringTodosHelper
|
|||
def recurring_todo_tag_list
|
||||
tags_except_starred = @recurring_todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME}
|
||||
tag_list = tags_except_starred.
|
||||
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.name.gsub(' ','-')}")}.
|
||||
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}")}.
|
||||
join('')
|
||||
return content_tag :span, tag_list.html_safe, :class => "tags"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def tag_span (tag, mobile=false)
|
||||
content_tag(:span, :class => "tag #{tag.name.gsub(' ','-')}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
|
||||
content_tag(:span, :class => "tag #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
|
||||
end
|
||||
|
||||
def tag_list(todo=@todo, mobile=false)
|
||||
|
|
|
|||
|
|
@ -26,4 +26,8 @@ class Tag < ActiveRecord::Base
|
|||
taggings.create :taggable => taggable, :user => user
|
||||
end
|
||||
|
||||
def label
|
||||
@label ||= name.gsub(' ', '-')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,5 +41,9 @@ class TagTest < ActiveSupport::TestCase
|
|||
|
||||
assert tag.name == "strip spaces"
|
||||
end
|
||||
|
||||
def test_tag_label
|
||||
assert_equal 'one-two-three', Tag.new(:name => 'one two three').label
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue