-
Notifications
You must be signed in to change notification settings - Fork 0
Makes it easy to get the right form of the verb or use 'you' correctly in your View.
License
jamesarosen/grammar
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Grammar adds verb and pronoun inflection support to ActiveSupport. With Grammar, you can do things like 'am'.second_person_plural # => 'are' 'have'.third_person_singular # => 'has' and @current_user = @john @user_to_display = @lucy Grammar::Pronoun.noun_or_pronoun(@user_to_display, @current_user) # => 'John' @current_user = @lucy Grammar::Pronoun.pronoun_or_noun(@user_to_display, @current_user) # => 'you' If you're using Rails (specifically, ActionPack), you can do the following: # in app/controllers/news_controller.rb: class NewsController < ApplicationController is_grammatical ... append_before_filter :load_grammatical_context ... def load_grammatical_context Grammar::GrammaticalContext.new(:audience => self.current_user) end end # in app/views/news/index.html.erb: ... <% @news_items.each do |item| -%> <% with_grammatical_context(:subject => item.follower, :object => item.followee) do |gc| -%> <%= gc.subject %> <%= gc.conjugate('is') %> now following <%= gc.object %>. <% end -%> <% end -%>
About
Makes it easy to get the right form of the verb or use 'you' correctly in your View.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published