1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Add an :escaped filter for escaped plain text.

This commit is contained in:
Nathan Weizenbaum 2008-05-10 22:37:49 -07:00
parent 3e922fbd42
commit d5ca228014
5 changed files with 20 additions and 1 deletions

View file

@ -655,6 +655,9 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
# [javascript] Surrounds the filtered text with <script> and CDATA tags.
# Useful for including inline Javascript.
#
# [escaped] Works the same as plain, but HTML-escapes the text
# before placing it in the document.
#
# [ruby] Parses the filtered text with the normal Ruby interpreter.
# All output sent to <tt>$stdout</tt>, like with +puts+,
# is output into the Haml document.

View file

@ -65,6 +65,7 @@ module Haml
'sass' => Haml::Filters::Sass,
'plain' => Haml::Filters::Plain,
'javascript' => Haml::Filters::Javascript,
'escaped' => Haml::Filters::Escaped,
'preserve' => Haml::Filters::Preserve,
'redcloth' => Haml::Filters::RedCloth,
'textile' => Haml::Filters::Textile,

View file

@ -156,6 +156,14 @@ END
end
end
module Escaped
include Base
def render(text)
Haml::Helpers.html_escape text
end
end
module Ruby
include Base
lazy_require 'stringio'

View file

@ -79,4 +79,6 @@ This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work
Text!
Hello, World!
How are you doing today?
&lt;div class=&quot;foo&quot;&gt;
&lt;p&gt;I think &amp;mdash; or do I?&lt;/p&gt;
&lt;/div&gt;

View file

@ -79,3 +79,8 @@
:ruby
printf "%s, World!\n", var
print "How are you doing today?\n"
:escaped
<div class="foo">
<p>I think &mdash; or do I?</p>
</div>