mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
parent
1e5a4ba48c
commit
3dbf1bf3d3
2 changed files with 17 additions and 1 deletions
|
@ -18,6 +18,8 @@
|
|||
to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
|
||||
* Fix #@foo and #$foo style interpolation that was not working in html_safe mode. (Akira Matsuda)
|
||||
* Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
|
||||
* The `haml` command's debug option (`-d`) no longer executes the Haml code, but
|
||||
rather checks the generated Ruby syntax for errors.
|
||||
|
||||
## 4.0.6
|
||||
|
||||
|
|
|
@ -309,7 +309,12 @@ END
|
|||
|
||||
if @options[:debug]
|
||||
puts engine.precompiled
|
||||
puts '=' * 100
|
||||
error = validate_ruby(engine.precompiled)
|
||||
if error
|
||||
puts '=' * 100
|
||||
puts error.message.split("\n")[0]
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
result = engine.to_html
|
||||
|
@ -326,6 +331,15 @@ END
|
|||
output.write(result)
|
||||
output.close() if output.is_a? File
|
||||
end
|
||||
|
||||
def validate_ruby(code)
|
||||
begin
|
||||
eval("BEGIN {return nil}; #{code}")
|
||||
# Not sure why, but rescuing "SyntaxError" does not work here.
|
||||
rescue Exception
|
||||
$!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue