2017-11-11 21:59:18 -05:00
|
|
|
" Author: Jake Zimmerman <jake@zimmerman.io>, Eddie Lebow https://github.com/elebow
|
2017-08-21 16:34:42 -04:00
|
|
|
" Description: eruby checker using `erubis`, instead of `erb`
|
|
|
|
|
2017-11-11 21:59:18 -05:00
|
|
|
function! ale_linters#eruby#erubis#GetCommand(buffer) abort
|
|
|
|
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
|
|
|
|
|
|
|
if empty(l:rails_root)
|
|
|
|
return 'erubis -x %t | ruby -c'
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Rails-flavored eRuby does not comply with the standard as understood by
|
|
|
|
" Erubis, so we'll have to do some substitution. This does not reduce the
|
|
|
|
" effectiveness of the linter—the translated code is still evaluated.
|
|
|
|
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . ' | ruby -c'
|
|
|
|
endfunction
|
|
|
|
|
2017-08-21 16:34:42 -04:00
|
|
|
call ale#linter#Define('eruby', {
|
|
|
|
\ 'name': 'erubis',
|
|
|
|
\ 'executable': 'erubis',
|
|
|
|
\ 'output_stream': 'stderr',
|
2017-11-11 21:59:18 -05:00
|
|
|
\ 'command_callback': 'ale_linters#eruby#erubis#GetCommand',
|
2017-08-21 16:34:42 -04:00
|
|
|
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
|
|
|
\})
|