mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
parent
56b037f733
commit
257cba3df5
3 changed files with 26 additions and 0 deletions
|
@ -72,6 +72,17 @@ module Hamlit
|
|||
|
||||
"#{length} #{label}#{'s' if length > 1}"
|
||||
end
|
||||
|
||||
# Replace hard tabs into 2 spaces
|
||||
def replace_hard_tabs(template)
|
||||
lines = []
|
||||
template.each_line do |line|
|
||||
lines << line.gsub(/^\t+/) do |match|
|
||||
' ' * (match.length * 2)
|
||||
end
|
||||
end
|
||||
lines.join
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,7 @@ module Hamlit
|
|||
# Reset the parser state.
|
||||
def reset(template)
|
||||
validate_indentation!(template)
|
||||
template = replace_hard_tabs(template)
|
||||
template = preprocess_multilines(template)
|
||||
|
||||
reset_lines(template.split("\n"))
|
||||
|
|
14
spec/hamlit/engine/indent_spec.rb
Normal file
14
spec/hamlit/engine/indent_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
describe Hamlit::Engine do
|
||||
describe 'tab indent' do
|
||||
it 'accepts tab indentation' do
|
||||
assert_render(<<-HAML, <<-HTML)
|
||||
%p
|
||||
\t%a
|
||||
HAML
|
||||
<p>
|
||||
<a></a>
|
||||
</p>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue