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:
parent
3e922fbd42
commit
d5ca228014
5 changed files with 20 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -79,4 +79,6 @@ This pre is pretty deeply
 nested.
 Does interpolation work
|
|||
Text!
|
||||
Hello, World!
|
||||
How are you doing today?
|
||||
|
||||
<div class="foo">
|
||||
<p>I think &mdash; or do I?</p>
|
||||
</div>
|
||||
|
|
|
@ -79,3 +79,8 @@
|
|||
:ruby
|
||||
printf "%s, World!\n", var
|
||||
print "How are you doing today?\n"
|
||||
|
||||
:escaped
|
||||
<div class="foo">
|
||||
<p>I think — or do I?</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue