mini-max-kit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/haml-7.2.0/CHANGELOG.md +1705 -0
  3. data/haml-7.2.0/FAQ.md +147 -0
  4. data/haml-7.2.0/Gemfile +25 -0
  5. data/haml-7.2.0/MIT-LICENSE +20 -0
  6. data/haml-7.2.0/README.md +205 -0
  7. data/haml-7.2.0/REFERENCE.md +1309 -0
  8. data/haml-7.2.0/Rakefile +48 -0
  9. data/haml-7.2.0/bin/bench +66 -0
  10. data/haml-7.2.0/bin/console +10 -0
  11. data/haml-7.2.0/bin/ruby +3 -0
  12. data/haml-7.2.0/bin/setup +7 -0
  13. data/haml-7.2.0/bin/stackprof +27 -0
  14. data/haml-7.2.0/bin/test +24 -0
  15. data/haml-7.2.0/exe/haml +6 -0
  16. data/haml-7.2.0/haml.gemspec +45 -0
  17. data/haml-7.2.0/lib/haml/ambles.rb +20 -0
  18. data/haml-7.2.0/lib/haml/attribute_builder.rb +162 -0
  19. data/haml-7.2.0/lib/haml/attribute_compiler.rb +133 -0
  20. data/haml-7.2.0/lib/haml/attribute_parser.rb +116 -0
  21. data/haml-7.2.0/lib/haml/cli.rb +154 -0
  22. data/haml-7.2.0/lib/haml/compiler/children_compiler.rb +155 -0
  23. data/haml-7.2.0/lib/haml/compiler/comment_compiler.rb +51 -0
  24. data/haml-7.2.0/lib/haml/compiler/doctype_compiler.rb +52 -0
  25. data/haml-7.2.0/lib/haml/compiler/script_compiler.rb +114 -0
  26. data/haml-7.2.0/lib/haml/compiler/silent_script_compiler.rb +24 -0
  27. data/haml-7.2.0/lib/haml/compiler/tag_compiler.rb +76 -0
  28. data/haml-7.2.0/lib/haml/compiler.rb +97 -0
  29. data/haml-7.2.0/lib/haml/dynamic_merger.rb +67 -0
  30. data/haml-7.2.0/lib/haml/engine.rb +59 -0
  31. data/haml-7.2.0/lib/haml/error.rb +66 -0
  32. data/haml-7.2.0/lib/haml/escape.rb +13 -0
  33. data/haml-7.2.0/lib/haml/escape_any.rb +21 -0
  34. data/haml-7.2.0/lib/haml/filters/base.rb +12 -0
  35. data/haml-7.2.0/lib/haml/filters/cdata.rb +20 -0
  36. data/haml-7.2.0/lib/haml/filters/coffee.rb +17 -0
  37. data/haml-7.2.0/lib/haml/filters/css.rb +33 -0
  38. data/haml-7.2.0/lib/haml/filters/erb.rb +10 -0
  39. data/haml-7.2.0/lib/haml/filters/escaped.rb +22 -0
  40. data/haml-7.2.0/lib/haml/filters/javascript.rb +33 -0
  41. data/haml-7.2.0/lib/haml/filters/less.rb +20 -0
  42. data/haml-7.2.0/lib/haml/filters/markdown.rb +11 -0
  43. data/haml-7.2.0/lib/haml/filters/plain.rb +29 -0
  44. data/haml-7.2.0/lib/haml/filters/preserve.rb +22 -0
  45. data/haml-7.2.0/lib/haml/filters/ruby.rb +10 -0
  46. data/haml-7.2.0/lib/haml/filters/sass.rb +15 -0
  47. data/haml-7.2.0/lib/haml/filters/scss.rb +15 -0
  48. data/haml-7.2.0/lib/haml/filters/text_base.rb +25 -0
  49. data/haml-7.2.0/lib/haml/filters/tilt_base.rb +59 -0
  50. data/haml-7.2.0/lib/haml/filters.rb +75 -0
  51. data/haml-7.2.0/lib/haml/force_escape.rb +29 -0
  52. data/haml-7.2.0/lib/haml/helpers.rb +15 -0
  53. data/haml-7.2.0/lib/haml/html.rb +22 -0
  54. data/haml-7.2.0/lib/haml/identity.rb +13 -0
  55. data/haml-7.2.0/lib/haml/object_ref.rb +35 -0
  56. data/haml-7.2.0/lib/haml/parser.rb +991 -0
  57. data/haml-7.2.0/lib/haml/rails_helpers.rb +53 -0
  58. data/haml-7.2.0/lib/haml/rails_template.rb +62 -0
  59. data/haml-7.2.0/lib/haml/railtie.rb +10 -0
  60. data/haml-7.2.0/lib/haml/ruby_expression.rb +32 -0
  61. data/haml-7.2.0/lib/haml/string_splitter.rb +140 -0
  62. data/haml-7.2.0/lib/haml/template.rb +20 -0
  63. data/haml-7.2.0/lib/haml/temple_line_counter.rb +31 -0
  64. data/haml-7.2.0/lib/haml/util.rb +262 -0
  65. data/haml-7.2.0/lib/haml/version.rb +4 -0
  66. data/haml-7.2.0/lib/haml/whitespace.rb +8 -0
  67. data/haml-7.2.0/lib/haml.rb +9 -0
  68. data/mini-max-kit.gemspec +12 -0
  69. metadata +108 -0
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/compiler/children_compiler'
3
+ require 'haml/compiler/comment_compiler'
4
+ require 'haml/compiler/doctype_compiler'
5
+ require 'haml/compiler/script_compiler'
6
+ require 'haml/compiler/silent_script_compiler'
7
+ require 'haml/compiler/tag_compiler'
8
+ require 'haml/filters'
9
+ require 'haml/identity'
10
+
11
+ module Haml
12
+ class Compiler
13
+ def initialize(options = {})
14
+ identity = Identity.new
15
+ @children_compiler = ChildrenCompiler.new
16
+ @comment_compiler = CommentCompiler.new
17
+ @doctype_compiler = DoctypeCompiler.new(options)
18
+ @filter_compiler = Filters.new(options)
19
+ @script_compiler = ScriptCompiler.new(identity, options)
20
+ @silent_script_compiler = SilentScriptCompiler.new
21
+ @tag_compiler = TagCompiler.new(identity, options)
22
+ end
23
+
24
+ def call(ast)
25
+ return runtime_error(ast) if ast.is_a?(Error)
26
+ compile(ast)
27
+ rescue Error => e
28
+ runtime_error(e)
29
+ end
30
+
31
+ private
32
+
33
+ def compile(node)
34
+ case node.type
35
+ when :root
36
+ compile_children(node)
37
+ when :comment
38
+ compile_comment(node)
39
+ when :doctype
40
+ compile_doctype(node)
41
+ when :filter
42
+ compile_filter(node)
43
+ when :plain
44
+ compile_plain(node)
45
+ when :script
46
+ compile_script(node)
47
+ when :silent_script
48
+ compile_silent_script(node)
49
+ when :tag
50
+ compile_tag(node)
51
+ when :haml_comment
52
+ [:multi]
53
+ else
54
+ raise InternalError.new("Unexpected node type: #{node.type}")
55
+ end
56
+ end
57
+
58
+ def compile_children(node)
59
+ @children_compiler.compile(node) { |n| compile(n) }
60
+ end
61
+
62
+ def compile_comment(node)
63
+ @comment_compiler.compile(node) { |n| compile_children(n) }
64
+ end
65
+
66
+ def compile_doctype(node)
67
+ @doctype_compiler.compile(node)
68
+ end
69
+
70
+ def compile_filter(node)
71
+ @filter_compiler.compile(node)
72
+ end
73
+
74
+ def compile_plain(node)
75
+ [:static, node.value[:text]]
76
+ end
77
+
78
+ def compile_script(node)
79
+ @script_compiler.compile(node) { |n| compile_children(n) }
80
+ end
81
+
82
+ def compile_silent_script(node)
83
+ @silent_script_compiler.compile(node) { |n| compile_children(n) }
84
+ end
85
+
86
+ def compile_tag(node)
87
+ @tag_compiler.compile(node) { |n| compile_children(n) }
88
+ end
89
+
90
+ def runtime_error(error)
91
+ [:multi].tap do |temple|
92
+ error.line.times { temple << [:newline] } if error.line
93
+ temple << [:code, %Q[raise #{error.class}.new(%q[#{error.message}], #{error.line.inspect})]]
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ # Compile [:multi, [:static, 'foo'], [:dynamic, 'bar']] to [:dynamic, '"foo#{bar}"']
4
+ class DynamicMerger < Temple::Filter
5
+ def on_multi(*exps)
6
+ exps = exps.dup
7
+ result = [:multi]
8
+ buffer = []
9
+
10
+ until exps.empty?
11
+ type, arg = exps.first
12
+ if type == :dynamic && arg.count("\n") == 0
13
+ buffer << exps.shift
14
+ elsif type == :static && exps.size > (count = arg.count("\n")) &&
15
+ exps[1, count].all? { |e| e == [:newline] }
16
+ (1 + count).times { buffer << exps.shift }
17
+ elsif type == :newline && exps.size > (count = count_newline(exps)) &&
18
+ exps[count].first == :static && count == exps[count].last.count("\n")
19
+ (count + 1).times { buffer << exps.shift }
20
+ else
21
+ result.concat(merge_dynamic(buffer))
22
+ buffer = []
23
+ result << compile(exps.shift)
24
+ end
25
+ end
26
+ result.concat(merge_dynamic(buffer))
27
+
28
+ result.size == 2 ? result[1] : result
29
+ end
30
+
31
+ private
32
+
33
+ def merge_dynamic(exps)
34
+ # Merge exps only when they have both :static and :dynamic
35
+ unless exps.any? { |type,| type == :static } && exps.any? { |type,| type == :dynamic }
36
+ return exps
37
+ end
38
+
39
+ strlit_body = String.new
40
+ exps.each do |type, arg|
41
+ case type
42
+ when :static
43
+ strlit_body << arg.dump.sub!(/\A"/, '').sub!(/"\z/, '').gsub('\n', "\n")
44
+ when :dynamic
45
+ strlit_body << "\#{#{arg}}"
46
+ when :newline
47
+ # newline is added by `gsub('\n', "\n")`
48
+ else
49
+ raise "unexpected type #{type.inspect} is given to #merge_dynamic"
50
+ end
51
+ end
52
+ [[:dynamic, "%Q\0#{strlit_body}\0"]]
53
+ end
54
+
55
+ def count_newline(exps)
56
+ count = 0
57
+ exps.each do |exp|
58
+ if exp == [:newline]
59
+ count += 1
60
+ else
61
+ return count
62
+ end
63
+ end
64
+ return count
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ require 'temple'
3
+ require 'haml/parser'
4
+ require 'haml/compiler'
5
+ require 'haml/html'
6
+ require 'haml/string_splitter'
7
+ require 'haml/escape'
8
+ require 'haml/escape_any'
9
+ require 'haml/force_escape'
10
+ require 'haml/dynamic_merger'
11
+ require 'haml/ambles'
12
+ require 'haml/whitespace'
13
+
14
+ module Haml
15
+ class Engine < Temple::Engine
16
+ define_options(
17
+ :buffer_class,
18
+ generator: Temple::Generators::StringBuffer,
19
+ format: :html,
20
+ attr_quote: '"',
21
+ escape_html: true,
22
+ escape_attrs: true,
23
+ autoclose: %w(area base basefont br col command embed frame
24
+ hr img input isindex keygen link menuitem meta
25
+ param source track wbr),
26
+ filename: '',
27
+ disable_capture: false,
28
+ remove_whitespace: false,
29
+ )
30
+
31
+ use Parser
32
+ use Compiler
33
+ use HTML
34
+ use StringSplitter
35
+ filter :StaticAnalyzer
36
+ use Escape
37
+ use EscapeAny
38
+ use ForceEscape
39
+ filter :ControlFlow
40
+ use Ambles
41
+ filter :MultiFlattener
42
+ use Whitespace
43
+ filter :StaticMerger
44
+ use DynamicMerger
45
+ use :Generator, -> { options[:generator] }
46
+ end
47
+
48
+ # For backward compatibility of Tilt integration. TODO: We should deprecate this
49
+ # and let Tilt have a native support of Haml 6. At least it generates warnings now.
50
+ class TempleEngine < Engine
51
+ def compile(template)
52
+ @precompiled = call(template)
53
+ end
54
+
55
+ def precompiled_with_ambles(_local_names, after_preamble:)
56
+ "#{after_preamble.tr("\n", ';')}#{@precompiled}".dup
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Error < StandardError
4
+ MESSAGES = {
5
+ bad_script_indent: '"%s" is indented at wrong level: expected %d, but was at %d.',
6
+ cant_run_filter: 'Can\'t run "%s" filter; you must require its dependencies first',
7
+ cant_use_tabs_and_spaces: "Indentation can't use both tabs and spaces.",
8
+ deeper_indenting: "The line was indented %d levels deeper than the previous line.",
9
+ filter_not_defined: 'Filter "%s" is not defined.',
10
+ gem_install_filter_deps: '"%s" filter\'s %s dependency missing: try installing it or adding it to your Gemfile',
11
+ illegal_element: "Illegal element: classes and ids must have values.",
12
+ illegal_nesting_content: "Illegal nesting: nesting within a tag that already has content is illegal.",
13
+ illegal_nesting_header: "Illegal nesting: nesting within a header command is illegal.",
14
+ illegal_nesting_line: "Illegal nesting: content can't be both given on the same line as %%%s and nested within it.",
15
+ illegal_nesting_plain: "Illegal nesting: nesting within plain text is illegal.",
16
+ illegal_nesting_self_closing: "Illegal nesting: nesting within a self-closing tag is illegal.",
17
+ inconsistent_indentation: "Inconsistent indentation: %s used for indentation, but the rest of the document was indented using %s.",
18
+ indenting_at_start: "Indenting at the beginning of the document is illegal.",
19
+ install_haml_contrib: 'To use the "%s" filter, please install the haml-contrib gem.',
20
+ invalid_attribute_list: 'Invalid attribute list: %s.',
21
+ invalid_filter_name: 'Invalid filter name ":%s".',
22
+ invalid_tag: 'Invalid tag: "%s".',
23
+ missing_if: 'Got "%s" with no preceding "if"',
24
+ no_ruby_code: "There's no Ruby code for %s to evaluate.",
25
+ self_closing_content: "Self-closing tags can't have content.",
26
+ unbalanced_brackets: 'Unbalanced brackets.',
27
+ no_end: <<-END
28
+ You don't need to use "- end" in Haml. Un-indent to close a block:
29
+ - if foo?
30
+ %strong Foo!
31
+ - else
32
+ Not foo.
33
+ %p This line is un-indented, so it isn't part of the "if" block
34
+ END
35
+ }.freeze
36
+
37
+ def self.message(key, *args)
38
+ string = MESSAGES[key] or raise "[HAML BUG] No error messages for #{key}"
39
+ (args.empty? ? string : string % args).rstrip
40
+ end
41
+
42
+ # The line of the template on which the error occurred.
43
+ #
44
+ # @return [Fixnum]
45
+ attr_reader :line
46
+
47
+ # @param message [String] The error message
48
+ # @param line [Fixnum] See \{#line}
49
+ def initialize(message = nil, line = nil)
50
+ super(message)
51
+ @line = line
52
+ end
53
+ end
54
+
55
+ # SyntaxError is the type of exception raised when Haml encounters an
56
+ # ill-formatted document.
57
+ # It's not particularly interesting,
58
+ # except in that it's a subclass of {Haml::Error}.
59
+ class SyntaxError < Error; end
60
+
61
+ # An invalid filter name was used.
62
+ class FilterNotFound < Error; end
63
+
64
+ # InternalError means that you hit a bug of Haml itself.
65
+ class InternalError < Error; end
66
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/util'
3
+
4
+ module Haml
5
+ class Escape < Temple::Filters::Escapable
6
+ def initialize(opts = {})
7
+ super
8
+ @escape_code = options[:escape_code] ||
9
+ "::Haml::Util.escape_html#{options[:use_html_safe] ? '_safe' : ''}((%s))"
10
+ @escaper = eval("proc {|v| #{@escape_code % 'v'} }")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/escape'
3
+
4
+ module Haml
5
+ # This module allows Temple::Filter to dispatch :fescape on `#compile`.
6
+ module EscapeanyDispathcer
7
+ def on_escapeany(flag, exp)
8
+ [:escapeany, flag, compile(exp)]
9
+ end
10
+ end
11
+ ::Temple::Filter.include EscapeanyDispathcer
12
+
13
+ # Unlike Haml::Escape, this calls to_s when not escaped.
14
+ class EscapeAny < Escape
15
+ alias_method :on_escapeany, :on_escape
16
+
17
+ def on_dynamic(value)
18
+ [:dynamic, @escape ? @escape_code % value : "(#{value}).to_s"]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/util'
3
+
4
+ module Haml
5
+ class Filters
6
+ class Base
7
+ def initialize(options = {})
8
+ @format = options[:format]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Cdata < TextBase
5
+ def compile(node)
6
+ compile_cdata(node)
7
+ end
8
+
9
+ private
10
+
11
+ def compile_cdata(node)
12
+ temple = [:multi]
13
+ temple << [:static, "<![CDATA[\n"]
14
+ compile_text!(temple, node, ' ')
15
+ temple << [:static, "\n]]>"]
16
+ temple
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Coffee < TiltBase
5
+ def compile(node)
6
+ require 'tilt/coffee' if explicit_require?('coffee')
7
+ temple = [:multi]
8
+ temple << [:static, "<script>\n"]
9
+ temple << compile_with_tilt(node, 'coffee', indent_width: 2)
10
+ temple << [:static, "</script>"]
11
+ temple
12
+ end
13
+ end
14
+
15
+ CoffeeScript = Coffee
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Css < TextBase
5
+ def compile(node)
6
+ case @format
7
+ when :xhtml
8
+ compile_xhtml(node)
9
+ else
10
+ compile_html(node)
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def compile_html(node)
17
+ temple = [:multi]
18
+ temple << [:static, "<style>\n"]
19
+ compile_text!(temple, node, ' ')
20
+ temple << [:static, "\n</style>"]
21
+ temple
22
+ end
23
+
24
+ def compile_xhtml(node)
25
+ temple = [:multi]
26
+ temple << [:static, "<style type='text/css'>\n /*<![CDATA[*/\n"]
27
+ compile_text!(temple, node, ' ')
28
+ temple << [:static, "\n /*]]>*/\n</style>"]
29
+ temple
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Erb < TiltBase
5
+ def compile(node)
6
+ precompiled_with_tilt(node, 'erb')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Escaped < Base
5
+ def compile(node)
6
+ text = node.value[:text].rstrip
7
+ temple = compile_text(text)
8
+ [:escape, true, temple]
9
+ end
10
+
11
+ private
12
+
13
+ def compile_text(text)
14
+ if ::Haml::Util.contains_interpolation?(text)
15
+ [:dynamic, ::Haml::Util.unescape_interpolation(text)]
16
+ else
17
+ [:static, text]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Javascript < TextBase
5
+ def compile(node)
6
+ case @format
7
+ when :xhtml
8
+ compile_xhtml(node)
9
+ else
10
+ compile_html(node)
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def compile_html(node)
17
+ temple = [:multi]
18
+ temple << [:static, "<script>\n"]
19
+ compile_text!(temple, node, ' ')
20
+ temple << [:static, "\n</script>"]
21
+ temple
22
+ end
23
+
24
+ def compile_xhtml(node)
25
+ temple = [:multi]
26
+ temple << [:static, "<script type='text/javascript'>\n //<![CDATA[\n"]
27
+ compile_text!(temple, node, ' ')
28
+ temple << [:static, "\n //]]>\n</script>"]
29
+ temple
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ # LESS support is deprecated since it requires therubyracer.gem,
3
+ # which is hard to maintain.
4
+ #
5
+ # It's not supported in Sprockets 3.0+ too.
6
+ # https://github.com/sstephenson/sprockets/pull/547
7
+ module Haml
8
+ class Filters
9
+ class Less < TiltBase
10
+ def compile(node)
11
+ require 'tilt/less' if explicit_require?('less')
12
+ temple = [:multi]
13
+ temple << [:static, "<style>\n"]
14
+ temple << compile_with_tilt(node, 'less', indent_width: 2)
15
+ temple << [:static, '</style>']
16
+ temple
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Markdown < TiltBase
5
+ def compile(node)
6
+ require 'tilt/redcarpet' if explicit_require?('markdown')
7
+ compile_with_tilt(node, 'markdown')
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/string_splitter'
3
+
4
+ module Haml
5
+ class Filters
6
+ class Plain < Base
7
+ def compile(node)
8
+ text = node.value[:text]
9
+ text = text.rstrip unless ::Haml::Util.contains_interpolation?(text) # for compatibility
10
+ [:multi, [:newline], *compile_plain(text)]
11
+ end
12
+
13
+ private
14
+
15
+ def compile_plain(text)
16
+ string_literal = ::Haml::Util.unescape_interpolation(text)
17
+ StringSplitter.compile(string_literal).map do |temple|
18
+ type, str = temple
19
+ case type
20
+ when :dynamic
21
+ [:escape, false, [:dynamic, str]]
22
+ else
23
+ temple
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Preserve < Base
5
+ def compile(node)
6
+ text = node.value[:text].rstrip + "\n"
7
+ text = text.gsub("\n", '&#x000A;')
8
+ compile_text(text)
9
+ end
10
+
11
+ private
12
+
13
+ def compile_text(text)
14
+ if ::Haml::Util.contains_interpolation?(text)
15
+ [:dynamic, ::Haml::Util.unescape_interpolation(text)]
16
+ else
17
+ [:static, text]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Ruby < Base
5
+ def compile(node)
6
+ [:multi, [:newline], [:code, node.value[:text]]]
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Sass < TiltBase
5
+ def compile(node)
6
+ require 'tilt/sass' if explicit_require?('sass')
7
+ temple = [:multi]
8
+ temple << [:static, "<style>\n"]
9
+ temple << compile_with_tilt(node, 'sass', indent_width: 2)
10
+ temple << [:static, "</style>"]
11
+ temple
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class Scss < TiltBase
5
+ def compile(node)
6
+ require 'tilt/sass' if explicit_require?('scss')
7
+ temple = [:multi]
8
+ temple << [:static, "<style>\n"]
9
+ temple << compile_with_tilt(node, 'scss', indent_width: 2)
10
+ temple << [:static, "</style>"]
11
+ temple
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Filters
4
+ class TextBase < Base
5
+ def compile_text!(temple, node, prefix)
6
+ text = node.value[:text].rstrip.gsub(/^/, prefix)
7
+ if ::Haml::Util.contains_interpolation?(node.value[:text])
8
+ # original: Haml::Filters#compile
9
+ text = ::Haml::Util.unescape_interpolation(text).gsub(/(\\+)n/) do |s|
10
+ escapes = $1.size
11
+ next s if escapes % 2 == 0
12
+ "#{'\\' * (escapes - 1)}\n"
13
+ end
14
+ text.prepend("\n")
15
+ temple << [:dynamic, text]
16
+ else
17
+ node.value[:text].split("\n").size.times do
18
+ temple << [:newline]
19
+ end
20
+ temple << [:static, text]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end