Module: Haml::Filters::Vignette
- Includes:
- Base
- Defined in:
- lib/vignette/filter.rb
Instance Method Summary collapse
-
#compile(compiler, text) ⇒ Object
Note, this is copied from haml/filter.rb Unless the text contained interpolation, haml seems to naturally cache the result.
-
#render_with_options(text, options) ⇒ Object
TODO: We need to find a way to disable caching.
Instance Method Details
#compile(compiler, text) ⇒ Object
Note, this is copied from haml/filter.rb Unless the text contained interpolation, haml seems to naturally cache the result. This was impossible, then to run a test based on session, etc. I removed that check from below.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vignette/filter.rb', line 17 def compile(compiler, text) filter = self compiler.instance_eval do return if [:suppress_eval] text = unescape_interpolation(text).gsub(/(\\+)n/) do |s| escapes = $1.size next s if escapes % 2 == 0 "#{'\\' * (escapes - 1)}\n" end # We need to add a newline at the beginning to get the # filter lines to line up (since the Haml filter contains # a line that doesn't show up in the source, namely the # filter name). Then we need to escape the trailing # newline so that the whole filter block doesn't take up # too many. text = %[\n#{text.sub(/\n"\Z/, "\\n\"")}] push_script <<RUBY.rstrip, :escape_html => false find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options)) RUBY return end rendered = Haml::Helpers::find_and_preserve(filter.(text, compiler.), compiler.[:preserve]) rendered.rstrip! rendered.gsub!("\n", "\n#{' ' * @output_tabs}") unless [:ugly] push_text(rendered) end |
#render_with_options(text, options) ⇒ Object
TODO: We need to find a way to disable caching
5 6 7 8 9 10 |
# File 'lib/vignette/filter.rb', line 5 def (text, ) splitter = "\n" splitter = '->' if text.include?('->') lines = text.split splitter lines.vignette end |