vignette 0.0.1pre1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vignette/filter.rb +34 -0
- data/lib/vignette/version.rb +1 -1
- metadata +4 -4
data/lib/vignette/filter.rb
CHANGED
@@ -8,4 +8,38 @@ module Haml::Filters::Vignette
|
|
8
8
|
lines = text.split splitter
|
9
9
|
lines.vignette
|
10
10
|
end
|
11
|
+
|
12
|
+
# Note, this is copied from haml/filter.rb
|
13
|
+
# Unless the text contained interpolation, haml seems
|
14
|
+
# to naturally cache the result. This was impossible,
|
15
|
+
# then to run a test based on session, etc.
|
16
|
+
# I removed that check from below.
|
17
|
+
def compile(compiler, text)
|
18
|
+
filter = self
|
19
|
+
compiler.instance_eval do
|
20
|
+
return if options[:suppress_eval]
|
21
|
+
|
22
|
+
text = unescape_interpolation(text).gsub(/(\\+)n/) do |s|
|
23
|
+
escapes = $1.size
|
24
|
+
next s if escapes % 2 == 0
|
25
|
+
"#{'\\' * (escapes - 1)}\n"
|
26
|
+
end
|
27
|
+
# We need to add a newline at the beginning to get the
|
28
|
+
# filter lines to line up (since the Haml filter contains
|
29
|
+
# a line that doesn't show up in the source, namely the
|
30
|
+
# filter name). Then we need to escape the trailing
|
31
|
+
# newline so that the whole filter block doesn't take up
|
32
|
+
# too many.
|
33
|
+
text = %[\n#{text.sub(/\n"\Z/, "\\n\"")}]
|
34
|
+
push_script <<RUBY.rstrip, :escape_html => false
|
35
|
+
find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options))
|
36
|
+
RUBY
|
37
|
+
return
|
38
|
+
end
|
39
|
+
|
40
|
+
rendered = Haml::Helpers::find_and_preserve(filter.render_with_options(text, compiler.options), compiler.options[:preserve])
|
41
|
+
rendered.rstrip!
|
42
|
+
rendered.gsub!("\n", "\n#{' ' * @output_tabs}") unless options[:ugly]
|
43
|
+
push_text(rendered)
|
44
|
+
end
|
11
45
|
end
|
data/lib/vignette/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vignette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Geoff Hayes
|
@@ -44,9 +44,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
|
-
- - ! '
|
47
|
+
- - ! '>='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project:
|
52
52
|
rubygems_version: 1.8.25
|