haml 5.2.2 → 6.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/test.yml +13 -9
- data/.gitignore +16 -16
- data/.yardopts +0 -3
- data/CHANGELOG.md +74 -3
- data/Gemfile +18 -11
- data/MIT-LICENSE +1 -1
- data/README.md +17 -23
- data/REFERENCE.md +63 -138
- data/Rakefile +48 -81
- data/bin/bench +66 -0
- data/bin/console +11 -0
- data/bin/ruby +3 -0
- data/bin/setup +7 -0
- data/bin/stackprof +27 -0
- data/bin/test +24 -0
- data/exe/haml +6 -0
- data/ext/haml/extconf.rb +10 -0
- data/ext/haml/haml.c +537 -0
- data/ext/haml/hescape.c +108 -0
- data/ext/haml/hescape.h +20 -0
- data/haml.gemspec +39 -37
- data/lib/haml/ambles.rb +20 -0
- data/lib/haml/attribute_builder.rb +134 -179
- data/lib/haml/attribute_compiler.rb +85 -194
- data/lib/haml/attribute_parser.rb +92 -126
- data/lib/haml/cli.rb +154 -0
- data/lib/haml/compiler/children_compiler.rb +126 -0
- data/lib/haml/compiler/comment_compiler.rb +39 -0
- data/lib/haml/compiler/doctype_compiler.rb +46 -0
- data/lib/haml/compiler/script_compiler.rb +116 -0
- data/lib/haml/compiler/silent_script_compiler.rb +24 -0
- data/lib/haml/compiler/tag_compiler.rb +76 -0
- data/lib/haml/compiler.rb +63 -296
- data/lib/haml/dynamic_merger.rb +67 -0
- data/lib/haml/engine.rb +44 -227
- data/lib/haml/error.rb +5 -4
- data/lib/haml/escapable.rb +6 -70
- data/lib/haml/filters/base.rb +12 -0
- data/lib/haml/filters/cdata.rb +20 -0
- data/lib/haml/filters/coffee.rb +17 -0
- data/lib/haml/filters/css.rb +33 -0
- data/lib/haml/filters/erb.rb +10 -0
- data/lib/haml/filters/escaped.rb +22 -0
- data/lib/haml/filters/javascript.rb +33 -0
- data/lib/haml/filters/less.rb +20 -0
- data/lib/haml/filters/markdown.rb +11 -0
- data/lib/haml/filters/plain.rb +29 -0
- data/lib/haml/filters/preserve.rb +22 -0
- data/lib/haml/filters/ruby.rb +10 -0
- data/lib/haml/filters/sass.rb +15 -0
- data/lib/haml/filters/scss.rb +15 -0
- data/lib/haml/filters/text_base.rb +25 -0
- data/lib/haml/filters/tilt_base.rb +49 -0
- data/lib/haml/filters.rb +54 -378
- data/lib/haml/force_escapable.rb +29 -0
- data/lib/haml/helpers.rb +3 -697
- data/lib/haml/html.rb +22 -0
- data/lib/haml/identity.rb +13 -0
- data/lib/haml/object_ref.rb +35 -0
- data/lib/haml/parser.rb +157 -22
- data/lib/haml/rails_helpers.rb +53 -0
- data/lib/haml/rails_template.rb +55 -0
- data/lib/haml/railtie.rb +3 -46
- data/lib/haml/ruby_expression.rb +32 -0
- data/lib/haml/string_splitter.rb +140 -0
- data/lib/haml/template.rb +15 -34
- data/lib/haml/temple_line_counter.rb +2 -1
- data/lib/haml/util.rb +17 -15
- data/lib/haml/version.rb +1 -2
- data/lib/haml.rb +8 -20
- metadata +208 -54
- data/.gitmodules +0 -3
- data/TODO +0 -24
- data/benchmark.rb +0 -70
- data/bin/haml +0 -9
- data/lib/haml/.gitattributes +0 -1
- data/lib/haml/buffer.rb +0 -182
- data/lib/haml/exec.rb +0 -347
- data/lib/haml/generator.rb +0 -42
- data/lib/haml/helpers/action_view_extensions.rb +0 -60
- data/lib/haml/helpers/action_view_mods.rb +0 -132
- data/lib/haml/helpers/action_view_xss_mods.rb +0 -60
- data/lib/haml/helpers/safe_erubi_template.rb +0 -20
- data/lib/haml/helpers/safe_erubis_template.rb +0 -33
- data/lib/haml/helpers/xss_mods.rb +0 -114
- data/lib/haml/options.rb +0 -273
- data/lib/haml/plugin.rb +0 -54
- data/lib/haml/sass_rails_filter.rb +0 -47
- data/lib/haml/template/options.rb +0 -27
- data/lib/haml/temple_engine.rb +0 -124
- data/yard/default/.gitignore +0 -1
- data/yard/default/fulldoc/html/css/common.sass +0 -15
- data/yard/default/layout/html/footer.erb +0 -12
data/lib/haml/plugin.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Haml
|
4
|
-
|
5
|
-
# This module makes Haml work with Rails using the template handler API.
|
6
|
-
class Plugin
|
7
|
-
class << self
|
8
|
-
attr_accessor :annotate_rendered_view_with_filenames
|
9
|
-
end
|
10
|
-
self.annotate_rendered_view_with_filenames = false
|
11
|
-
|
12
|
-
def handles_encoding?; true; end
|
13
|
-
|
14
|
-
def compile(template, source)
|
15
|
-
options = Haml::Template.options.dup
|
16
|
-
if template.respond_to?(:type)
|
17
|
-
options[:mime_type] = template.type
|
18
|
-
elsif template.respond_to? :mime_type
|
19
|
-
options[:mime_type] = template.mime_type
|
20
|
-
end
|
21
|
-
options[:filename] = template.identifier
|
22
|
-
|
23
|
-
preamble = '@output_buffer = output_buffer ||= ActionView::OutputBuffer.new if defined?(ActionView::OutputBuffer);'
|
24
|
-
postamble = ''
|
25
|
-
|
26
|
-
if self.class.annotate_rendered_view_with_filenames
|
27
|
-
# short_identifier is only available in Rails 6+. On older versions, 'inspect' gives similar results.
|
28
|
-
ident = template.respond_to?(:short_identifier) ? template.short_identifier : template.inspect
|
29
|
-
preamble += "haml_concat '<!-- BEGIN #{ident} -->'.html_safe;"
|
30
|
-
postamble += "haml_concat '<!-- END #{ident} -->'.html_safe;"
|
31
|
-
end
|
32
|
-
|
33
|
-
Haml::Engine.new(source, options).compiler.precompiled_with_ambles(
|
34
|
-
[],
|
35
|
-
after_preamble: preamble,
|
36
|
-
before_postamble: postamble
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.call(template, source = nil)
|
41
|
-
source ||= template.source
|
42
|
-
|
43
|
-
new.compile(template, source)
|
44
|
-
end
|
45
|
-
|
46
|
-
def cache_fragment(block, name = {}, options = nil)
|
47
|
-
@view.fragment_for(block, name, options) do
|
48
|
-
eval("_hamlout.buffer", block.binding)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
ActionView::Template.register_template_handler(:haml, Haml::Plugin)
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Haml
|
4
|
-
module Filters
|
5
|
-
# This is an extension of Sass::Rails's SassTemplate class that allows
|
6
|
-
# Rails's asset helpers to be used inside Haml Sass filter.
|
7
|
-
class SassRailsTemplate < ::Sass::Rails::SassTemplate
|
8
|
-
if Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('3.0.0')
|
9
|
-
def render(scope=Object.new, locals={}, &block)
|
10
|
-
environment = ::Sprockets::Railtie.build_environment(::Rails.application)
|
11
|
-
scope = environment.context_class.new(
|
12
|
-
environment: environment,
|
13
|
-
filename: "/",
|
14
|
-
metadata: {}
|
15
|
-
)
|
16
|
-
super
|
17
|
-
end
|
18
|
-
else
|
19
|
-
def render(scope=Object.new, locals={}, &block)
|
20
|
-
scope = ::Rails.application.assets.context_class.new(::Rails.application.assets, "/", "/")
|
21
|
-
super
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def sass_options(scope)
|
26
|
-
options = super
|
27
|
-
options[:custom][:resolver] = ::ActionView::Base.new
|
28
|
-
options
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# This is an extension of Sass::Rails's SassTemplate class that allows
|
33
|
-
# Rails's asset helpers to be used inside a Haml SCSS filter.
|
34
|
-
class ScssRailsTemplate < SassRailsTemplate
|
35
|
-
self.default_mime_type = 'text/css'
|
36
|
-
|
37
|
-
def syntax
|
38
|
-
:scss
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
remove_filter :Sass
|
43
|
-
remove_filter :Scss
|
44
|
-
register_tilt_filter "Sass", :extend => "Css", :template_class => SassRailsTemplate
|
45
|
-
register_tilt_filter "Scss", :extend => "Css", :template_class => ScssRailsTemplate
|
46
|
-
end
|
47
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# We keep options in its own self-contained file
|
4
|
-
# so that we can load it independently in Rails 3,
|
5
|
-
# where the full template stuff is lazy-loaded.
|
6
|
-
|
7
|
-
module Haml
|
8
|
-
module Template
|
9
|
-
extend self
|
10
|
-
|
11
|
-
class Options < Hash
|
12
|
-
def []=(key, value)
|
13
|
-
super
|
14
|
-
if Haml::Options.buffer_defaults.key?(key)
|
15
|
-
Haml::Options.buffer_defaults[key] = value
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
@options = ::Haml::Template::Options.new
|
21
|
-
# The options hash for Haml when used within Rails.
|
22
|
-
# See {file:REFERENCE.md#options the Haml options documentation}.
|
23
|
-
#
|
24
|
-
# @return [Haml::Template::Options<Symbol => Object>]
|
25
|
-
attr_accessor :options
|
26
|
-
end
|
27
|
-
end
|
data/lib/haml/temple_engine.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'temple'
|
4
|
-
require 'haml/escapable'
|
5
|
-
require 'haml/generator'
|
6
|
-
|
7
|
-
module Haml
|
8
|
-
class TempleEngine < Temple::Engine
|
9
|
-
define_options(
|
10
|
-
attr_wrapper: "'",
|
11
|
-
autoclose: %w(area base basefont br col command embed frame
|
12
|
-
hr img input isindex keygen link menuitem meta
|
13
|
-
param source track wbr),
|
14
|
-
encoding: nil,
|
15
|
-
escape_attrs: true,
|
16
|
-
escape_html: false,
|
17
|
-
escape_filter_interpolations: nil,
|
18
|
-
filename: '(haml)',
|
19
|
-
format: :html5,
|
20
|
-
hyphenate_data_attrs: true,
|
21
|
-
line: 1,
|
22
|
-
mime_type: 'text/html',
|
23
|
-
preserve: %w(textarea pre code),
|
24
|
-
remove_whitespace: false,
|
25
|
-
suppress_eval: false,
|
26
|
-
cdata: false,
|
27
|
-
parser_class: ::Haml::Parser,
|
28
|
-
compiler_class: ::Haml::Compiler,
|
29
|
-
trace: false,
|
30
|
-
filters: {},
|
31
|
-
)
|
32
|
-
|
33
|
-
use :Parser, -> { options[:parser_class] }
|
34
|
-
use :Compiler, -> { options[:compiler_class] }
|
35
|
-
use Escapable
|
36
|
-
filter :ControlFlow
|
37
|
-
filter :MultiFlattener
|
38
|
-
filter :StaticMerger
|
39
|
-
use Generator
|
40
|
-
|
41
|
-
def compile(template)
|
42
|
-
initialize_encoding(template, options[:encoding])
|
43
|
-
@precompiled = call(template)
|
44
|
-
end
|
45
|
-
|
46
|
-
# The source code that is evaluated to produce the Haml document.
|
47
|
-
#
|
48
|
-
# This is automatically converted to the correct encoding
|
49
|
-
# (see {file:REFERENCE.md#encodings the `:encoding` option}).
|
50
|
-
#
|
51
|
-
# @return [String]
|
52
|
-
def precompiled
|
53
|
-
encoding = Encoding.find(@encoding || '')
|
54
|
-
return @precompiled.dup.force_encoding(encoding) if encoding == Encoding::ASCII_8BIT
|
55
|
-
return @precompiled.encode(encoding)
|
56
|
-
end
|
57
|
-
|
58
|
-
def precompiled_with_return_value
|
59
|
-
"#{precompiled};#{precompiled_method_return_value}".dup
|
60
|
-
end
|
61
|
-
|
62
|
-
# The source code that is evaluated to produce the Haml document.
|
63
|
-
#
|
64
|
-
# This is automatically converted to the correct encoding
|
65
|
-
# (see {file:REFERENCE.md#encodings the `:encoding` option}).
|
66
|
-
#
|
67
|
-
# @return [String]
|
68
|
-
def precompiled_with_ambles(local_names, after_preamble: '', before_postamble: '')
|
69
|
-
preamble = <<END.tr("\n", ';')
|
70
|
-
begin
|
71
|
-
extend Haml::Helpers
|
72
|
-
_hamlout = @haml_buffer = Haml::Buffer.new(haml_buffer, #{Options.new(options).for_buffer.inspect})
|
73
|
-
_erbout = _hamlout.buffer
|
74
|
-
#{after_preamble}
|
75
|
-
END
|
76
|
-
postamble = <<END.tr("\n", ';')
|
77
|
-
#{before_postamble}
|
78
|
-
#{precompiled_method_return_value}
|
79
|
-
ensure
|
80
|
-
@haml_buffer = @haml_buffer.upper if @haml_buffer
|
81
|
-
end
|
82
|
-
END
|
83
|
-
"#{preamble}#{locals_code(local_names)}#{precompiled}#{postamble}".dup
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
def initialize_encoding(template, given_value)
|
89
|
-
if given_value
|
90
|
-
@encoding = given_value
|
91
|
-
else
|
92
|
-
@encoding = Encoding.default_internal || template.encoding
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Returns the string used as the return value of the precompiled method.
|
97
|
-
# This method exists so it can be monkeypatched to return modified values.
|
98
|
-
def precompiled_method_return_value
|
99
|
-
"_erbout"
|
100
|
-
end
|
101
|
-
|
102
|
-
def locals_code(names)
|
103
|
-
names = names.keys if Hash === names
|
104
|
-
|
105
|
-
names.map do |name|
|
106
|
-
# Can't use || because someone might explicitly pass in false with a symbol
|
107
|
-
sym_local = "_haml_locals[#{inspect_obj(name.to_sym)}]"
|
108
|
-
str_local = "_haml_locals[#{inspect_obj(name.to_s)}]"
|
109
|
-
"#{name} = #{sym_local}.nil? ? #{str_local} : #{sym_local};"
|
110
|
-
end.join
|
111
|
-
end
|
112
|
-
|
113
|
-
def inspect_obj(obj)
|
114
|
-
case obj
|
115
|
-
when String
|
116
|
-
%Q!"#{obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]}}"!
|
117
|
-
when Symbol
|
118
|
-
":#{inspect_obj(obj.to_s)}"
|
119
|
-
else
|
120
|
-
obj.inspect
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
data/yard/default/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.css
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#filecontents
|
2
|
-
*:target, dt:target + dd
|
3
|
-
background-color: #ccf
|
4
|
-
border: 1px solid #88b
|
5
|
-
dt
|
6
|
-
font-weight: bold
|
7
|
-
dd
|
8
|
-
margin:
|
9
|
-
left: 0
|
10
|
-
bottom: 0.7em
|
11
|
-
padding-left: 3em
|
12
|
-
dt:target
|
13
|
-
border-bottom-style: none
|
14
|
-
& + dd
|
15
|
-
border-top-style: none
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<%= superb :footer %>
|
2
|
-
<% if ENV["ANALYTICS"] %>
|
3
|
-
<script type="text/javascript">
|
4
|
-
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
5
|
-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
6
|
-
</script>
|
7
|
-
<script type="text/javascript">
|
8
|
-
try {
|
9
|
-
var pageTracker = _gat._getTracker("<%= ENV["ANALYTICS"] %>");
|
10
|
-
pageTracker._trackPageview();
|
11
|
-
} catch(err) {}</script>
|
12
|
-
<% end %>
|