5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/barista/haml_filter.rb', line 5
def render_with_options(text, options)
type = render_type
case type
when :coffeescript
content_type = 'text/coffeescript'
cdata_wrapper = '#%s'
inner = text
when :javascript
content_type = 'text/javascript'
cdata_wrapper = '//%s'
inner = Barista::Compiler.compile(text)
end
output = []
output << "<script type=#{options[:attr_wrapper]}#{content_type(type)}#{options[:attr_wrapper]}>"
output << " #{cdata_wrapper % '<![CDATA['}"
output << " #{inner}".rstrip.gsub("\n", "\n ")
output << " #{cdata_wrapper % ']]>'}"
output << "</script>"
output.join("\n")
end
|