1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Allow tab indentation

Fixes #9.
This commit is contained in:
Takashi Kokubun 2015-04-02 23:51:35 +09:00
parent 56b037f733
commit 257cba3df5
3 changed files with 26 additions and 0 deletions

View file

@ -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

View file

@ -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"))

View 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