minimal 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/minimal/template/beautify_html.rb +19 -0
- data/lib/minimal/template.rb +5 -4
- data/lib/minimal/version.rb +1 -1
- metadata +4 -3
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'tidy_ffi'
|
2
|
+
|
3
|
+
module Minimal::Template::BeautifyHtml
|
4
|
+
OPTIONS = {
|
5
|
+
:indent => 'yes',
|
6
|
+
:indent_spaces => '2',
|
7
|
+
:wrap => '0'
|
8
|
+
}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def after(controller)
|
12
|
+
# controller.response.body = tidy(controller.response.body) if controller.request.format.html?
|
13
|
+
end
|
14
|
+
|
15
|
+
def tidy(html)
|
16
|
+
TidyFFI::Tidy.new(html, OPTIONS).clean
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/minimal/template.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class Minimal::Template
|
2
|
+
autoload :BeautifyHtml, 'minimal/template/beautify_html'
|
2
3
|
autoload :FormBuilderProxy, 'minimal/template/form_builder_proxy'
|
3
4
|
autoload :Handler, 'minimal/template/handler'
|
4
5
|
autoload :TranslatedTags, 'minimal/template/translated_tags'
|
5
6
|
|
6
|
-
AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|_for)
|
7
|
+
AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|[^l]_for)
|
7
8
|
TAG_NAMES = %w(a body div em fieldset h1 h2 h3 h4 h5 h6 head html img input label li link
|
8
9
|
ol option p pre script select span strong table thead tbody tfoot td title th tr ul)
|
9
10
|
|
@@ -11,7 +12,7 @@ class Minimal::Template
|
|
11
12
|
attr_accessor :view, :locals, :block
|
12
13
|
|
13
14
|
def initialize(view = nil)
|
14
|
-
@view, @locals, @
|
15
|
+
@view, @locals, @_auto_buffer = view, {}, {}
|
15
16
|
end
|
16
17
|
|
17
18
|
def _render(locals = nil, format = :html, &block)
|
@@ -27,7 +28,7 @@ class Minimal::Template
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def <<(output)
|
30
|
-
view.output_buffer << output
|
31
|
+
view.output_buffer << output
|
31
32
|
end
|
32
33
|
|
33
34
|
def respond_to?(method)
|
@@ -47,7 +48,7 @@ class Minimal::Template
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def auto_buffer?(method)
|
50
|
-
@
|
51
|
+
@_auto_buffer.key?(method) ? @_auto_buffer[method] : @_auto_buffer[method] = AUTO_BUFFER =~ method.to_s
|
51
52
|
end
|
52
53
|
end
|
53
54
|
include Base
|
data/lib/minimal/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|
@@ -58,6 +58,7 @@ extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
59
59
|
|
60
60
|
files:
|
61
|
+
- lib/minimal/template/beautify_html.rb
|
61
62
|
- lib/minimal/template/form_builder_proxy.rb
|
62
63
|
- lib/minimal/template/handler.rb
|
63
64
|
- lib/minimal/template/translated_tags.rb
|