Skip to content

Commit

Permalink
Always keep symbols in the context
Browse files Browse the repository at this point in the history
This simplifies #find a bit
  • Loading branch information
foca authored and defunkt committed Oct 4, 2009
1 parent 46617ef commit 4c3a6be
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/mustache.rb
Expand Up @@ -56,11 +56,11 @@ def context

# Context accessors
def [](key)
context[key]
context[key.to_sym]
end

def []=(key, value)
context[key] = value
context[key.to_sym] = value
end

# How we turn a view object into HTML. The main method, if you will.
Expand Down Expand Up @@ -175,9 +175,7 @@ def escape(string)
# strings and symbols) then call methods on the view object.
def find(name)
name.strip!
if @context.has_key? name
@context[name]
elsif @context.has_key? name.to_sym
if @context.has_key? name.to_sym
@context[name.to_sym]
elsif respond_to? name
send name
Expand Down

0 comments on commit 4c3a6be

Please sign in to comment.