Skip to content

Commit

Permalink
Template can handle its own escaping, thanks
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Oct 11, 2009
1 parent d545a3e commit 27a0c18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 0 additions & 6 deletions lib/mustache.rb
@@ -1,4 +1,3 @@
require 'cgi'
require 'mustache/template'
require 'mustache/context'

Expand Down Expand Up @@ -128,11 +127,6 @@ def self.underscore(classified)
string.gsub(/[A-Z]/) { |s| "_#{s.downcase}"}
end

# Escape HTML.
def self.escape(string)
CGI.escapeHTML(string.to_s)
end

# Turns a string into a Mustache::Template. If passed a Template,
# returns it.
def self.templateify(obj)
Expand Down
4 changes: 3 additions & 1 deletion lib/mustache/template.rb
@@ -1,3 +1,5 @@
require 'cgi'

class Mustache
# A Template is a compiled version of a Mustache template.
#
Expand Down Expand Up @@ -105,7 +107,7 @@ def str(s)

# {{}} - an escaped tag
def etag(s)
ev("Mustache.escape(ctx[#{s.strip.to_sym.inspect}])")
ev("CGI.escapeHTML(ctx[#{s.strip.to_sym.inspect}].to_s)")
end

# {{{}}} - an unescaped tag
Expand Down

0 comments on commit 27a0c18

Please sign in to comment.